Update app/main.py
This commit is contained in:
31
app/main.py
31
app/main.py
@@ -1,29 +1,14 @@
|
||||
import uvicorn
|
||||
from typing import Union
|
||||
|
||||
from fastapi import FastAPI
|
||||
from type.response import JsonResponMsg, Msg
|
||||
from type.client import UserID, User
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return {"Hello": "World"}
|
||||
|
||||
@app.get("/userID", response_model=JsonResponMsg)
|
||||
async def getUserById(userID: UserID) -> JsonResponMsg:
|
||||
|
||||
return {
|
||||
"status": 200,
|
||||
"body": {
|
||||
"message": f"args- {userID}",
|
||||
"tag": f"args- {userID}"
|
||||
}
|
||||
}
|
||||
|
||||
@app.post("/userID", response_model=JsonResponMsg)
|
||||
async def newUserById(user: User) -> JsonResponMsg:
|
||||
|
||||
return JsonResponMsg(
|
||||
status= 200,
|
||||
body=Msg(
|
||||
message=user["name"],
|
||||
tag=str(user["userId"])
|
||||
)
|
||||
)
|
||||
@app.get("/items/{item_id}")
|
||||
def read_item(item_id: int, q: str = None):
|
||||
return {"item_id": item_id, "q": q}
|
||||
Reference in New Issue
Block a user