mirror of
https://github.com/fastapi/fastapi.git
synced 2026-10-20 08:55:24 -04:00
📝 Update docs and examples for Response Model with Return Type Annotations, and update runtime error (#5873)
This commit is contained in:
1 parent
6b83525ff4
commit
fb8e9083f4
18 files changed
+757
-1
No files matched your search
@@ -0,0 +1,13 @@
|
||||
from typing import Union
|
||||
|
||||
from fastapi import FastAPI, Response
|
||||
from fastapi.responses import RedirectResponse
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/portal", response_model=None)
|
||||
async def get_portal(teleport: bool = False) -> Union[Response, dict]:
|
||||
if teleport:
|
||||
return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
||||
return {"message": "Here's your interdimensional portal."}
|
||||
Reference in new issue
Block a user