Files
fastapi/docs_src/response_cookies/tutorial001_py310.py
2026-02-12 14:19:43 +01:00

13 lines
344 B
Python

from fastapi import FastAPI
from fastapi.responses import JSONResponse
app = FastAPI()
@app.post("/cookie/")
def create_cookie():
content = {"message": "Come to the dark side, we have cookies"}
response = JSONResponse(content=content)
response.set_cookie(key="fakesession", value="fake-cookie-session-value")
return response