mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-23 22:29:34 -05:00
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com> Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
13 lines
299 B
Python
13 lines
299 B
Python
from fastapi import FastAPI, HTTPException
|
|
|
|
app = FastAPI()
|
|
|
|
items = {"foo": "The Foo Wrestlers"}
|
|
|
|
|
|
@app.get("/items/{item_id}")
|
|
async def read_item(item_id: str):
|
|
if item_id not in items:
|
|
raise HTTPException(status_code=404, detail="Item not found")
|
|
return {"item": items[item_id]}
|