Songyou commited on
Commit
d38f766
·
1 Parent(s): 1b10c0c
Files changed (1) hide show
  1. main.py +5 -2
main.py CHANGED
@@ -3,6 +3,9 @@ from fastapi.responses import JSONResponse, HTMLResponse
3
  import logging
4
  app = FastAPI()
5
 
 
 
 
6
  @app.get("/", response_class=HTMLResponse)
7
  async def read_root():
8
  # 提供前端 HTML 文件
@@ -11,10 +14,10 @@ async def read_root():
11
 
12
 
13
  @app.post("/submit")
14
- async def submit_input(input_data: str):
15
  # 处理用户输入并返回响应
16
  logging.info("input coming")
17
-
18
  return JSONResponse(content={"message": input_data.user_input})
19
 
20
 
 
3
  import logging
4
  app = FastAPI()
5
 
6
+ class InputData(BaseModel):
7
+ user_input: str
8
+
9
  @app.get("/", response_class=HTMLResponse)
10
  async def read_root():
11
  # 提供前端 HTML 文件
 
14
 
15
 
16
  @app.post("/submit")
17
+ async def submit_input(input_data: InputData):
18
  # 处理用户输入并返回响应
19
  logging.info("input coming")
20
+ logging.info(input_data)
21
  return JSONResponse(content={"message": input_data.user_input})
22
 
23