Spaces:
Runtime error
Runtime error
File size: 398 Bytes
b64b305 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
from fastapi import FastAPI
from pydantic import BaseModel
from backend import predict
app = FastAPI()
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}
|