docs_src/response_headers/tutorial001_py310.py
raw| 1 | from fastapi import FastAPI |
| 2 | from fastapi.responses import JSONResponse |
| 3 | |
| 4 | app = FastAPI() |
| 5 | |
| 6 | |
| 7 | @app.get("/headers/") |
| 8 | def get_headers(): |
| 9 | content = {"message": "Hello World"} |
| 10 | headers = {"X-Cat-Dog": "alone in the world", "Content-Language": "en-US"} |
| 11 | return JSONResponse(content=content, headers=headers) |