LLM-fastAPI / main.py
Songyou's picture
Update main.py
9031187 verified
raw
history blame
591 Bytes
from fastapi import FastAPI
from fastapi.responses import JSONResponse, HTMLResponse
from pydantic import BaseModel
import logging
app = FastAPI()
class InputData(BaseModel):
user_input: str
@app.get("/", response_class=HTMLResponse)
async def read_root():
# 提供前端 HTML 文件
with open("index.html", "r") as file:
return file.read()
@app.post("/submit")
async def submit_input(input_data: InputData):
# 处理用户输入并返回响应
print("input coming")
print(input_data)
return JSONResponse(content={"message": input_data.user_input})