BuckLakeAI / app.py
parkerjj's picture
Uploading Model
cfe1a3c
raw
history blame
648 Bytes
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
#from preprocess import preprocess_text
# 初始化 FastAPI 应用
app = FastAPI()
# 定义请求体模型
class TextRequest(BaseModel):
text: str
@app.post("/api/preprocess")
async def api_preprocess(request: TextRequest):
"""
API: 接收新闻文本,返回预处理结果。
"""
if not request.text.strip():
raise HTTPException(status_code=400, detail="Text cannot be empty.")
result = request.text + 'ABC'
return result
# 启动服务
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)