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


Python responses.RedirectResponse方法代码示例

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


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

示例1: get

# 需要导入模块: from starlette import responses [as 别名]
# 或者: from starlette.responses import RedirectResponse [as 别名]
def get(self, request: Request) -> Response:

        # validate state
        state = request.query_params["state"]
        _state = request.session.pop("state", "unknown")
        if state != _state:
            return PlainTextResponse("Invalid state", status_code=403)

        # retrieve tokens
        code = request.query_params["code"]
        tokens = self.kc.callback(code)
        # request.session["tokens"] = json.dumps(tokens)

        # retrieve user info
        access_token = tokens["access_token"]
        user = self.kc.fetch_userinfo(access_token)
        request.session["user"] = json.dumps(user)

        return RedirectResponse(self.redirect_uri) 
开发者ID:chunky-monkeys,项目名称:keycloak-client,代码行数:21,代码来源:starlette.py

示例2: docs_redirect

# 需要导入模块: from starlette import responses [as 别名]
# 或者: from starlette.responses import RedirectResponse [as 别名]
def docs_redirect():
    return RedirectResponse(f"{prefix}/docs") 
开发者ID:microsoft,项目名称:cookiecutter-spacy-fastapi,代码行数:4,代码来源:api.py

示例3: _get_badge_url

# 需要导入模块: from starlette import responses [as 别名]
# 或者: from starlette.responses import RedirectResponse [as 别名]
def _get_badge_url(owner, repo, ext, style):
    return responses.RedirectResponse(
        url=f"https://img.shields.io/endpoint.{ext}?url=https://dashboard.mergify.io/badges/{owner}/{repo}&style={style}",
        status_code=302,
    ) 
开发者ID:Mergifyio,项目名称:mergify-engine,代码行数:7,代码来源:web.py

示例4: badge

# 需要导入模块: from starlette import responses [as 别名]
# 或者: from starlette.responses import RedirectResponse [as 别名]
def badge(owner, repo):
    return responses.RedirectResponse(
        url=f"https://dashboard.mergify.io/badges/{owner}/{repo}"
    ) 
开发者ID:Mergifyio,项目名称:mergify-engine,代码行数:6,代码来源:web.py

示例5: index

# 需要导入模块: from starlette import responses [as 别名]
# 或者: from starlette.responses import RedirectResponse [as 别名]
def index():  # pragma: no cover
    return responses.RedirectResponse(url="https://mergify.io/") 
开发者ID:Mergifyio,项目名称:mergify-engine,代码行数:4,代码来源:web.py

示例6: handle_exc

# 需要导入模块: from starlette import responses [as 别名]
# 或者: from starlette.responses import RedirectResponse [as 别名]
def handle_exc(request, exc):
    print(request, exc)
    return RedirectResponse(url='/redirect') 
开发者ID:MushroomMaula,项目名称:fastapi_login,代码行数:5,代码来源:test_login_manager.py

示例7: redirect_root_to_docs

# 需要导入模块: from starlette import responses [as 别名]
# 或者: from starlette.responses import RedirectResponse [as 别名]
def redirect_root_to_docs(fast_app: FastAPI, func_name: str, endpoint: str, method: str) -> None:
    """Adds api route to server that redirects user from root to docs with opened `endpoint` description."""

    @fast_app.get('/', include_in_schema=False)
    async def redirect_to_docs() -> RedirectResponse:
        operation_id = generate_operation_id_for_path(name=func_name, path=endpoint, method=method)
        response = RedirectResponse(url=f'/docs#/default/{operation_id}')
        return response 
开发者ID:deepmipt,项目名称:DeepPavlov,代码行数:10,代码来源:server.py

示例8: response

# 需要导入模块: from starlette import responses [as 别名]
# 或者: from starlette.responses import RedirectResponse [as 别名]
def response(self) -> RedirectResponse:
        return RedirectResponse(url=self._url, status_code=self.status_code) 
开发者ID:bocadilloproject,项目名称:bocadillo,代码行数:4,代码来源:redirection.py


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