pythonasyncioapiasyncfastapiframeworkjsonjson-schemaopenapiopenapi3pydanticpython-typespython3redocreststarletteswaggerswagger-uiuvicornweb
11 lines
259 B
11 lines
259 B
from typing import Union
|
|
|
|
from fastapi import FastAPI, Header
|
|
from typing_extensions import Annotated
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/items/")
|
|
async def read_items(user_agent: Annotated[Union[str, None], Header()] = None):
|
|
return {"User-Agent": user_agent}
|
|
|