test / app.py
Turkeyengineer's picture
Update app.py
2d63baf verified
raw
history blame
564 Bytes
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
app = FastAPI()
@app.post("/run_predict")
async def run_predict(request: Request):
try:
body = await request.json()
sentences = body.get("data", [])
results = [" / ".join(list(s)) for s in sentences]
return JSONResponse(content={"data": results})
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
if __name__ == "__main__":
import uvicorn
uvicorn.run("app:app", host="0.0.0.0", port=7860)