SentimentPro / app.py
rabindra-sss's picture
Update app.py
c0910c7 verified
raw
history blame contribute delete
593 Bytes
import streamlit as st
from fastapi import FastAPI
from pydantic import BaseModel
from backend import predict
st.title("Classify Sentiment")
text= st.text_area("Enter your text")
if(text):
prediction= predict(text)
st.header(prediction)
st.json({"sentiment": prediction})
app = FastAPI()
class Input(BaseModel):
text: str
@app.get("/")
async def root():
return {"message": "SentimentPro API is running!"}
@app.post("/predict/")
async def predict_sentiment(input: Input):
prediction = predict(input.text)
return {"text": input.text, "sentiment": prediction}