Coverage for docs_src / cookie_param_models / tutorial002_an_py310.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1from typing import Annotated 1abefcd

2 

3from fastapi import Cookie, FastAPI 1abefcd

4from pydantic import BaseModel 1abefcd

5 

6app = FastAPI() 1abefcd

7 

8 

9class Cookies(BaseModel): 1abefcd

10 model_config = {"extra": "forbid"} 1abefcd

11 

12 session_id: str 1abcd

13 fatebook_tracker: str | None = None 1abefcd

14 googall_tracker: str | None = None 1abefcd

15 

16 

17@app.get("/items/") 1abefcd

18async def read_items(cookies: Annotated[Cookies, Cookie()]): 1abefcd

19 return cookies 1ghijklm