mirror of
https://github.com/fastapi/fastapi.git
synced 2026-10-29 03:04:42 +08:00
15 lines
270 B
Python
15 lines
270 B
Python
from fastapi import Cookie, FastAPI
|
|
from pydantic import BaseModel
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class Preferences(BaseModel):
|
|
theme: str
|
|
locale: str
|
|
|
|
|
|
@app.get("/items/")
|
|
async def read_items(preferences: Preferences | None = Cookie(default=None)):
|
|
return preferences
|