mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-12 01:31:03 -04:00
📝 Update docs and examples for Response Model with Return Type Annotations, and update runtime error (#5873)
This commit is contained in:
committed by
GitHub
parent
6b83525ff4
commit
fb8e9083f4
11
docs_src/response_model/tutorial003_02.py
Normal file
11
docs_src/response_model/tutorial003_02.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from fastapi import FastAPI, Response
|
||||
from fastapi.responses import JSONResponse, RedirectResponse
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/portal")
|
||||
async def get_portal(teleport: bool = False) -> Response:
|
||||
if teleport:
|
||||
return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
||||
return JSONResponse(content={"message": "Here's your interdimensional portal."})
|
||||
Reference in New Issue
Block a user