当前位置: 首页>>代码示例>>Python>>正文


Python web.redirect方法代码示例

本文整理汇总了Python中web.redirect方法的典型用法代码示例。如果您正苦于以下问题:Python web.redirect方法的具体用法?Python web.redirect怎么用?Python web.redirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在web的用法示例。


在下文中一共展示了web.redirect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: POST

# 需要导入模块: import web [as 别名]
# 或者: from web import redirect [as 别名]
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") 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:18,代码来源:nightmare_frontend.py

示例2: _delegate

# 需要导入模块: import web [as 别名]
# 或者: from web import redirect [as 别名]
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:]) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:27,代码来源:cookieless_app.py

示例3: action_download

# 需要导入模块: import web [as 别名]
# 或者: from web import redirect [as 别名]
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() 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:19,代码来源:task_edit_file.py

示例4: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import redirect [as 别名]
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() 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:36,代码来源:tasks.py

示例5: GET_AUTH

# 需要导入模块: import web [as 别名]
# 或者: from web import redirect [as 别名]
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)) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:8,代码来源:lti.py

示例6: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import redirect [as 别名]
def GET(self):
        return web.redirect("/static/index.html") 
开发者ID:vineetchoudhary,项目名称:Apple-iOS-MDM-Server,代码行数:4,代码来源:server.py

示例7: POST

# 需要导入模块: import web [as 别名]
# 或者: from web import redirect [as 别名]
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") 
开发者ID:joxeankoret,项目名称:cosa-nostra,代码行数:38,代码来源:cosa_nostra.py

示例8: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import redirect [as 别名]
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) 
开发者ID:rucio,项目名称:rucio,代码行数:49,代码来源:account.py


注:本文中的web.redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。