2022-05-14 06:59:59 -05:00
|
|
|
from typing import Union
|
2020-06-28 20:13:30 +02:00
|
|
|
|
2018-12-13 21:05:15 +04:00
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
2018-12-13 21:48:37 +04:00
|
|
|
|
2018-12-13 21:25:45 +04:00
|
|
|
@app.get("/items/{item_id}")
|
2022-05-14 06:59:59 -05:00
|
|
|
async def read_item(item_id: str, q: Union[str, None] = None, short: bool = False):
|
2018-12-13 21:25:45 +04:00
|
|
|
item = {"item_id": item_id}
|
2018-12-13 21:05:15 +04:00
|
|
|
if q:
|
|
|
|
|
item.update({"q": q})
|
|
|
|
|
if not short:
|
2018-12-13 21:48:37 +04:00
|
|
|
item.update(
|
|
|
|
|
{"description": "This is an amazing item that has a long description"}
|
|
|
|
|
)
|
2018-12-13 21:05:15 +04:00
|
|
|
return item
|