mirror of
https://github.com/fastapi/fastapi.git
synced 2026-11-09 01:23:17 -05:00
17 lines
305 B
Python
17 lines
305 B
Python
from typing import Annotated
|
|
|
|
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: Annotated[Preferences | None, Cookie()] = None):
|
|
return preferences
|