Spaces:
Runtime error
Runtime error
File size: 465 Bytes
cd23520 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from fastapi import FastAPI
from pydantic import BaseModel
from backend import predict
from mangum import Mangum
app = FastAPI()
handler = Mangum(app)
class Input(BaseModel):
text: str
@app.get("/")
async def root():
return {"message": "Sentiment Analysis API is running!"}
@app.post("/predict/")
async def predict_sentiment(input: Input):
prediction = predict(input.text)
return {"text": input.text, "sentiment": prediction}
|