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

8 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from fastapi import FastAPI, Response 1abcde

2from fastapi.responses import JSONResponse, RedirectResponse 1abcde

3 

4app = FastAPI() 1abcde

5 

6 

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

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

9 if teleport: 1abcde

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

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