-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
39 lines (23 loc) · 881 Bytes
/
app.py
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
30
31
32
33
34
35
36
37
38
39
from typing import Optional, List
import uvicorn
from fastapi import FastAPI
from models import User, UserWithEnum
from custom import DeepQuery
app = FastAPI(version="0.1.0", docs_url="/")
@app.get("/optional-search")
async def search(user: Optional[User] = DeepQuery(Optional[User], name="bob")):
print(user)
@app.get("/enum-search")
async def search(user: UserWithEnum = DeepQuery(UserWithEnum, name="bob")):
print(user)
@app.get("/search")
async def search(user: User = DeepQuery(User, name="bob")):
print(user)
@app.get("/searchs")
async def searchs(users: List[User] = DeepQuery(List[User])):
print(users)
@app.get("/unique-searchs")
async def searchs(users: List[User] = DeepQuery(List[User], unique_on=["role"])):
print(users)
if __name__ == "__main__":
uvicorn.run("app:app", port=5555, host="0.0.0.0", reload=True, log_config=None)