Python starlette.responses.RedirectResponse() Examples
The following are 9
code examples of starlette.responses.RedirectResponse().
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
starlette.responses
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: starlette.py From keycloak-client with GNU General Public License v3.0 | 6 votes |
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)
Example #2
Source File: api.py From cookiecutter-spacy-fastapi with MIT License | 5 votes |
def docs_redirect(): return RedirectResponse(f"{prefix}/docs")
Example #3
Source File: web.py From mergify-engine with Apache License 2.0 | 5 votes |
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, )
Example #4
Source File: web.py From mergify-engine with Apache License 2.0 | 5 votes |
def badge(owner, repo): return responses.RedirectResponse( url=f"https://dashboard.mergify.io/badges/{owner}/{repo}" )
Example #5
Source File: web.py From mergify-engine with Apache License 2.0 | 5 votes |
def index(): # pragma: no cover return responses.RedirectResponse(url="https://mergify.io/")
Example #6
Source File: starlette.py From keycloak-client with GNU General Public License v3.0 | 5 votes |
def get(self, request: Request) -> Response: url, state = self.kc.login() request.session["state"] = state return RedirectResponse(url)
Example #7
Source File: test_login_manager.py From fastapi_login with MIT License | 5 votes |
def handle_exc(request, exc): print(request, exc) return RedirectResponse(url='/redirect')
Example #8
Source File: server.py From DeepPavlov with Apache License 2.0 | 5 votes |
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
Example #9
Source File: redirection.py From bocadillo with MIT License | 5 votes |
def response(self) -> RedirectResponse: return RedirectResponse(url=self._url, status_code=self.status_code)