justapi — /docs
from justapi import JustAPIApp, Cookie

app = JustAPIApp()

@app.get("/check")
def check_session(session_id: str = Cookie(...)):
    return {"session_id": session_id}

Required vs Optional

@app.get("/check")
def check(
    session_id: str = Cookie(...),        # required
    language: str = Cookie("en"),          # optional, defaults to "en"
    theme: str = Cookie(None),            # optional, defaults to None
):
    return {"session_id": session_id, "language": language, "theme": theme}
from pydantic import BaseModel
from justapi import JustAPIApp, Cookie

class Cookies(BaseModel):
    session_id: str
    language: str = "en"
    theme: str = "light"

app = JustAPIApp()

@app.get("/check")
def check(cookies: Cookies = Cookie(...)):
    return cookies.model_dump()

See Also

JustAPI v2.0.9 — Open Source MIT License · Built with WebTUI · GitHub

NORMAL master justapi/docs
utf-8 Top 1:1