mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-29 08:21:16 -05:00
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
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}
|