SentimentPro_API / main.py
rabindra-sss's picture
Rename app.py to main.py
6cf2235 verified
raw
history blame
465 Bytes
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}