mirror of https://github.com/tiangolo/fastapi.git
22 lines
435 B
Python
22 lines
435 B
Python
from typing import Union
|
|
|
|
from fastapi import Cookie, FastAPI
|
|
from pydantic import BaseModel
|
|
from typing_extensions import Annotated
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class Cookies(BaseModel):
|
|
class Config:
|
|
extra = "forbid"
|
|
|
|
session_id: str
|
|
fatebook_tracker: Union[str, None] = None
|
|
googall_tracker: Union[str, None] = None
|
|
|
|
|
|
@app.get("/items/")
|
|
async def read_items(cookies: Annotated[Cookies, Cookie()]):
|
|
return cookies
|