Update app/main.py
This commit is contained in:
32
app/main.py
32
app/main.py
@@ -1,11 +1,29 @@
|
|||||||
from typing import Union
|
import uvicorn
|
||||||
|
from fastapi import FastAPI
|
||||||
from fastapi import FastAPI, Request
|
from type.response import JsonResponMsg, Msg
|
||||||
|
from type.client import UserID, User
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/{item_id}")
|
@app.get("/userID", response_model=JsonResponMsg)
|
||||||
def read_root(item_id: str, request: Request):
|
async def getUserById(userID: UserID) -> JsonResponMsg:
|
||||||
client_host = request.client.host
|
|
||||||
return {"client_host": client_host, "item_id": item_id}
|
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"])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user