30 lines
656 B
Python
30 lines
656 B
Python
import uvicorn
|
|
from fastapi import FastAPI
|
|
from type.response import JsonResponMsg, Msg
|
|
from type.client import UserID, User
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@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"])
|
|
)
|
|
)
|