From 5e16b96092e5f18a485584216d692ae97f19bde8 Mon Sep 17 00:00:00 2001 From: administrator Date: Thu, 15 Feb 2024 17:46:07 +0800 Subject: [PATCH] Update app/main.py --- app/main.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/app/main.py b/app/main.py index ba63c8c..ce0cae8 100644 --- a/app/main.py +++ b/app/main.py @@ -1,11 +1,29 @@ -from typing import Union - -from fastapi import FastAPI, Request +import uvicorn +from fastapi import FastAPI +from type.response import JsonResponMsg, Msg +from type.client import UserID, User app = FastAPI() -@app.get("/items/{item_id}") -def read_root(item_id: str, request: Request): - client_host = request.client.host - return {"client_host": client_host, "item_id": item_id} \ No newline at end of file +@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"]) + ) + )