Coverage for docs_src / response_model / tutorial003_02_py310.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-12 18:15 +0000

1from fastapi import FastAPI, Response 1abcd

2from fastapi.responses import JSONResponse, RedirectResponse 1abcd

3 

4app = FastAPI() 1abcd

5 

6 

7@app.get("/portal") 1abcd

8async def get_portal(teleport: bool = False) -> Response: 1abcd

9 if teleport: 1efghij

10 return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ") 1fhj

11 return JSONResponse(content={"message": "Here's your interdimensional portal."}) 1egi