fastapi-master/docs_src/response_cookies/tutorial002.py

10 lines
272 B
Python
Raw Permalink Normal View History

2024-08-24 12:41:47 +08:00
from fastapi import FastAPI, Response
app = FastAPI()
@app.post("/cookie-and-object/")
def create_cookie(response: Response):
response.set_cookie(key="fakesession", value="fake-cookie-session-value")
return {"message": "Come to the dark side, we have cookies"}