Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from fastapi.responses import JSONResponse, HTMLResponse | |
| from pydantic import BaseModel | |
| import logging | |
| app = FastAPI() | |
| class InputData(BaseModel): | |
| user_input: str | |
| async def read_root(): | |
| # 提供前端 HTML 文件 | |
| with open("index.html", "r") as file: | |
| return file.read() | |
| async def submit_input(input_data: InputData): | |
| # 处理用户输入并返回响应 | |
| print("input coming") | |
| print(input_data) | |
| return JSONResponse(content={"message": input_data.user_input}) | |