mirror of https://github.com/tiangolo/fastapi.git
17 lines
373 B
Python
17 lines
373 B
Python
from typing import Annotated
|
|
|
|
from fastapi import FastAPI, Path
|
|
from fastapi.param_functions import Query
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/items/{item_id}")
|
|
async def read_items(item_id: Annotated[int, Path(gt=0)]):
|
|
return {"item_id": item_id}
|
|
|
|
|
|
@app.get("/users")
|
|
async def read_users(user_id: Annotated[str, Query(min_length=1)] = "me"):
|
|
return {"user_id": user_id}
|