docs_src/response_model/tutorial003_04_py310.py
raw| 1 | from fastapi import FastAPI, Response |
| 2 | from fastapi.responses import RedirectResponse |
| 3 | |
| 4 | app = FastAPI() |
| 5 | |
| 6 | |
| 7 | @app.get("/portal") |
| 8 | async def get_portal(teleport: bool = False) -> Response | dict: |
| 9 | if teleport: |
| 10 | return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ") |
| 11 | return {"message": "Here's your interdimensional portal."} |