當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。