-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (22 loc) · 695 Bytes
/
main.py
File metadata and controls
29 lines (22 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from fastapi import FastAPI, Query
from typing import Annotated
app = FastAPI()
fake_data: dict[str, list[dict[int, str]]] = {
"items": [
{1: "Apple"},
{2: "Banana"}
]
}
# @app.get("/items", tags=["Items"])
# async def get_item(q: str | None = None):
# print(q)
# return {"hello": "world"}
@app.get("/items", tags=["Items"])
async def get_item(query: Annotated[str, Query(title="Get All Item", description="item get description", alias="sabbir-hossain", deprecated=False)] = None):
print(query)
if query:
fake_data.update({"query": query})
return fake_data
@app.get("/", tags=["Helth"])
async def helth():
return {"hello": "world"}