2022-05-13 18:38:22 -05:00
|
|
|
from typing import Union
|
2020-06-28 20:13:30 +02:00
|
|
|
|
2018-12-14 17:10:08 +04:00
|
|
|
from fastapi import FastAPI, Query
|
|
|
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/items/")
|
|
|
|
|
async def read_items(
|
2022-05-13 18:38:22 -05:00
|
|
|
q: Union[str, None] = Query(
|
|
|
|
|
default=None,
|
2018-12-14 17:10:08 +04:00
|
|
|
title="Query string",
|
|
|
|
|
description="Query string for the items to search in the database that have a good match",
|
|
|
|
|
min_length=3,
|
2023-10-25 00:26:06 +04:00
|
|
|
),
|
2018-12-14 17:10:08 +04:00
|
|
|
):
|
|
|
|
|
results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
|
|
|
|
|
if q:
|
|
|
|
|
results.update({"q": q})
|
|
|
|
|
return results
|