Query 매개 변수를 정의하는 것과 동일한 방식으로 쿠키 매개변수를 정의하고 사용 할 수 있다.
Cookie는 fastapi 패키지에서 가져와 사용한다.
from typing import Annotated
from fastapi import Cookie, FastAPI
app = FastAPI()
@app.get("/items/")
async def read_items(ads_id: Annotated[str | None, Cookie()] = None):
return {"ads_id": ads_id}
'FrameWork > Fastapi' 카테고리의 다른 글
[Fastapi] Header 매개 변수 (0) | 2023.05.12 |
---|---|
[Fastapi] Body Fields을 통한 유효성 검증, 중첩 모델 (0) | 2023.05.12 |
[Fastapi] Body Multiple Parameters (0) | 2023.05.12 |
[Fastapi] 경로 매개 변수에서의 유효성 검증 (1) | 2023.05.12 |
[Fastapi] 유효성 검사, 필수 매개변수, 쿼리 매개변수 목록/다중 값 처리 (0) | 2023.05.12 |