Python web.redirect() Examples
The following are 13
code examples of web.redirect().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
web
, or try the search function
.
Example #1
Source File: nightmare_frontend.py From nightmare with GNU General Public License v2.0 | 6 votes |
def POST(self): if not 'user' in session or session.user is None: f = register_form() return render.login(f) i = web.input(id=-1, sure="") if i.id == -1: return render.error("Invalid project identifier") elif i.sure != "on": return render.error("You must check the \"I'm sure\" field.") db = init_web_db() with db.transaction(): vars={"project_id":i.id} where = "project_id=$project_id" db.delete("projects", where=where, vars=vars) return web.redirect("/projects")
Example #2
Source File: nightmare_frontend.py From nightmare with GNU General Public License v2.0 | 6 votes |
def POST(self): if not 'user' in session or session.user is None: f = register_form() return render.login(f) i = web.input(name="", description="", command="") if i.name == "": return render.error("No mutation engine name specified") elif i.description == "": return render.error("No mutation engine description specified") elif i.command == "": return render.error("No mutation engine command specified") elif i.command.find("%OUTPUT%") == -1: return render.error("No output mutated filename specified in the mutation engine command") db = init_web_db() with db.transaction(): db.insert("mutation_engines", name=i.name, command=i.command, description=i.description, date=web.SQLLiteral("CURRENT_DATE")) return web.redirect("/engines") #-----------------------------------------------------------------------
Example #3
Source File: nightmare_frontend.py From nightmare with GNU General Public License v2.0 | 6 votes |
def POST(self): if not 'user' in session or session.user is None: f = register_form() return render.login(f) i = web.input(id=-1, name="", description="", command="") if i.id == -1: return render.error("Invalid mutation engine identifier") elif i.name == "": return render.error("No mutation engine name specified") elif i.description == "": return render.error("No mutation engine description specified") elif i.command == "": return render.error("No mutation engine command specified") elif i.command.find("%OUTPUT%") == -1: return render.error("No output mutated filename specified in the mutation engine command") db = init_web_db() with db.transaction(): where = "mutation_engine_id = $id" vars = {"id":i.id} db.update("mutation_engines", name=i.name, command=i.command, description=i.description, where=where, vars=vars) return web.redirect("/engines")
Example #4
Source File: cookieless_app.py From INGInious with GNU Affero General Public License v3.0 | 6 votes |
def _delegate(self, f, fvars, args=None): if args is None: args = [None] # load session if args[0] == "/@@": self._session.load('') # creates a new session raise web.redirect("/@" + self._session.session_id + "@"+web.ctx.fullpath[3:]) # redirect to the same page, with the new # session id elif args[0] is None: self._session.load(None) else: self._session.load(args[0][2:len(args[0])-1]) # Switch language if specified input_data = web.input() if "lang" in input_data: self._session.language = input_data["lang"] elif "language" not in self._session: for lang in re.split("[,;]+", web.ctx.environ.get("HTTP_ACCEPT_LANGUAGE", "")): if lang in self._translations.keys(): self._session.language = lang break return super(CookieLessCompatibleApplication, self)._delegate(f, fvars, args[1:])
Example #5
Source File: task_edit_file.py From INGInious with GNU Affero General Public License v3.0 | 6 votes |
def action_download(self, courseid, taskid, path): """ Download a file or a directory """ wanted_path = self.verify_path(courseid, taskid, path) if wanted_path is None: raise web.notfound() task_fs = self.task_factory.get_task_fs(courseid, taskid) (method, mimetype_or_none, file_or_url) = task_fs.distribute(wanted_path) if method == "local": web.header('Content-Type', mimetype_or_none) return file_or_url elif method == "url": raise web.redirect(file_or_url) else: raise web.notfound()
Example #6
Source File: nightmare_frontend.py From nightmare with GNU General Public License v2.0 | 5 votes |
def POST(self): if not 'user' in session or session.user is None: f = register_form() return render.login(f) i = web.input(name="", description="", subfolder="", tube_prefix="", max_files=100, max_iteration=1000000, ignore_duplicates=0) if i.name == "": return render.error("No project name specified") elif i.description == "": return render.error("No project description specified") elif i.tube_prefix == "": return render.error("Invalid tube prefix") if i.ignore_duplicates == "on": ignore_duplicates = 1 else: ignore_duplicates = 0 db = init_web_db() with db.transaction(): db.insert("projects", name=i.name, description=i.description, subfolder=i.subfolder, tube_prefix=i.tube_prefix, maximum_samples=i.max_files, archived=0, maximum_iteration=i.max_iteration, date=web.SQLLiteral("CURRENT_DATE"), ignore_duplicates=ignore_duplicates) return web.redirect("/projects") #-----------------------------------------------------------------------
Example #7
Source File: tasks.py From INGInious with GNU Affero General Public License v3.0 | 5 votes |
def GET(self, courseid, taskid, path): # pylint: disable=arguments-differ """ GET request """ try: course = self.course_factory.get_course(courseid) if not self.user_manager.course_is_open_to_user(course): return handle_course_unavailable(self.app.get_homepath(), self.template_helper, self.user_manager, course) path_norm = posixpath.normpath(urllib.parse.unquote(path)) if taskid == "$common": public_folder = course.get_fs().from_subfolder("$common").from_subfolder("public") else: task = course.get_task(taskid) if not self.user_manager.task_is_visible_by_user(task): # ignore LTI check here return self.template_helper.get_renderer().task_unavailable() public_folder = task.get_fs().from_subfolder("public") (method, mimetype_or_none, file_or_url) = public_folder.distribute(path_norm, False) if method == "local": web.header('Content-Type', mimetype_or_none) return file_or_url elif method == "url": raise web.redirect(file_or_url) else: raise web.notfound() except web.HTTPError as error_or_redirect: raise error_or_redirect except: if web.config.debug: raise else: raise web.notfound()
Example #8
Source File: lti.py From INGInious with GNU Affero General Public License v3.0 | 5 votes |
def GET_AUTH(self, asset_url): data = self.user_manager.session_lti_info() if data is None: raise web.notfound() (courseid, _) = data['task'] raise web.redirect(self.app.get_homepath() + "/course/{courseid}/{asset_url}".format(courseid=courseid, asset_url=asset_url))
Example #9
Source File: server.py From Apple-iOS-MDM-Server with MIT License | 5 votes |
def GET(self): return web.redirect("/static/index.html")
Example #10
Source File: cosa_nostra.py From cosa-nostra with GNU General Public License v3.0 | 5 votes |
def POST(self): if not 'user' in session or session.user is None: f = register_form() return render.login(f) i = web.input(anal_engine="", ida_path="", pyew_path="") if i.anal_engine == "" or (i.ida_path + i.pyew_path == ""): render.error("Invalid analysis engine, IDA path or Pyew path.") db = open_db() with db.transaction(): sql = "select 1 from config where name = 'IDA_PATH'" res = list(db.query(sql)) if len(res) > 0: sql = "update config set value = $value where name = 'IDA_PATH'" else: sql = "insert into config (name, value) values ('IDA_PATH', $value)" db.query(sql, vars={"value":i.ida_path}) sql = "select 1 from config where name = 'PYEW_PATH'" res = list(db.query(sql)) if len(res) > 0: sql = "update config set value = $value where name = 'PYEW_PATH'" else: sql = "insert into config (name, value) values ('PYEW_PATH', $value)" db.query(sql, vars={"value":i.pyew_path}) sql = "select 1 from config where name = 'ANAL_ENGINE'" res = list(db.query(sql)) if len(res) > 0: sql = "update config set value = $value where name = 'ANAL_ENGINE'" else: sql = "insert into config (name, value) values ('ANAL_ENGINE', $value)" db.query(sql, vars={"value":i.anal_engine}) return web.redirect("/config")
Example #11
Source File: account.py From rucio with Apache License 2.0 | 4 votes |
def GET(self, account): """ get account information for given account name. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 404 Not Found 406 Not Acceptable 500 InternalError :param Rucio-Account: Account identifier. :param Rucio-Auth-Token: as an 32 character hex string. :returns: JSON dict containing informations about the requested user. """ header('Content-Type', 'application/json') if account == 'whoami': # Redirect to the account uri frontend = ctx.env.get('HTTP_X_REQUESTED_HOST') if frontend: raise redirect(frontend + "/accounts/%s" % (ctx.env.get('issuer'))) raise seeother(ctx.env.get('issuer')) acc = None try: acc = get_account_info(account) except AccountNotFound as error: raise generate_http_error(404, 'AccountNotFound', error.args[0]) except AccessDenied as error: raise generate_http_error(401, 'AccessDenied', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error) dict = acc.to_dict() for key, value in dict.items(): if isinstance(value, datetime): dict[key] = value.strftime('%Y-%m-%dT%H:%M:%S') del dict['_sa_instance_state'] return render_json(**dict)
Example #12
Source File: account.py From rucio with Apache License 2.0 | 4 votes |
def GET(self, account): """ get account information for given account name. HTTP Success: 200 OK HTTP Error: 401 Unauthorized 404 Not Found 406 Not Acceptable 500 InternalError :param Rucio-Account: Account identifier. :param Rucio-Auth-Token: as an 32 character hex string. :returns: JSON dict containing informations about the requested user. """ header('Content-Type', 'application/json') if account == 'whoami': # Redirect to the account uri frontend = ctx.env.get('HTTP_X_REQUESTED_HOST') if frontend: raise redirect(frontend + "/accounts/%s" % (ctx.env.get('issuer'))) raise seeother(ctx.env.get('issuer')) acc = None try: acc = get_account_info(account) except AccountNotFound as error: raise generate_http_error(404, 'AccountNotFound', error.args[0]) except AccessDenied as error: raise generate_http_error(401, 'AccessDenied', error.args[0]) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error) dict = acc.to_dict() for key, value in dict.items(): if isinstance(value, datetime): dict[key] = value.strftime('%Y-%m-%dT%H:%M:%S') del dict['_sa_instance_state'] return render_json(**dict)
Example #13
Source File: nightmare_frontend.py From nightmare with GNU General Public License v2.0 | 4 votes |
def POST(self): if not 'user' in session or session.user is None: f = register_form() return render.login(f) i = web.input(id=-1, name="", description="", subfolder="", tube_prefix="", enabled="", archived="", ignore_duplicates=0) if i.id == -1: return render.error("Invalid project identifier") elif i.name == "": return render.error("No project name specified") elif i.description == "": return render.error("No project description specified") elif i.tube_prefix == "": return render.error("No tube prefix specified") if i.enabled == "on": enabled = 1 else: enabled = 0 if i.archived == "on": archived = 1 else: archived = 0 if i.ignore_duplicates == "on": ignore_duplicates = 1 else: ignore_duplicates = 0 db = init_web_db() with db.transaction(): enabled = i.enabled == "on" archived = i.archived == "on" db.update("projects", name=i.name, description=i.description, subfolder=i.subfolder, tube_prefix=i.tube_prefix, maximum_samples=i.max_files, enabled=enabled, maximum_iteration=i.max_iteration, archived=archived, where="project_id = $project_id", ignore_duplicates=ignore_duplicates, vars={"project_id":i.id}) return web.redirect("/projects")