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>
17 lines
283 B
Python
17 lines
283 B
Python
from fastapi import FastAPI
|
|
|
|
app = FastAPI()
|
|
|
|
items = {}
|
|
|
|
|
|
@app.on_event("startup")
|
|
async def startup_event():
|
|
items["foo"] = {"name": "Fighters"}
|
|
items["bar"] = {"name": "Tenders"}
|
|
|
|
|
|
@app.get("/items/{item_id}")
|
|
async def read_items(item_id: str):
|
|
return items[item_id]
|