mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-04 23:23:38 -04:00
* ✨ Add support for declaring a Response parameter to set headers and cookies * ✅ Add source for docs and tests * 📝 Add docs for setting headers, cookies and status code * 📝 Add attribution to Hug for inspiring response parameters
11 lines
253 B
Python
11 lines
253 B
Python
from fastapi import FastAPI
|
|
from starlette.responses import Response
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/headers-and-object/")
|
|
def get_headers(response: Response):
|
|
response.headers["X-Cat-Dog"] = "alone in the world"
|
|
return {"message": "Hello World"}
|