Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
-
from backend import predict
|
2 |
import streamlit as st
|
|
|
|
|
|
|
3 |
|
4 |
st.title("Classify Sentiment")
|
5 |
|
@@ -8,4 +10,20 @@ text= st.text_area("Enter your text")
|
|
8 |
if(text):
|
9 |
prediction= predict(text)
|
10 |
st.header(prediction)
|
11 |
-
st.json({"sentiment": prediction})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from fastapi import FastAPI
|
3 |
+
from pydantic import BaseModel
|
4 |
+
from backend import predict
|
5 |
|
6 |
st.title("Classify Sentiment")
|
7 |
|
|
|
10 |
if(text):
|
11 |
prediction= predict(text)
|
12 |
st.header(prediction)
|
13 |
+
st.json({"sentiment": prediction})
|
14 |
+
|
15 |
+
|
16 |
+
app = FastAPI()
|
17 |
+
|
18 |
+
|
19 |
+
class Input(BaseModel):
|
20 |
+
text: str
|
21 |
+
|
22 |
+
@app.get("/")
|
23 |
+
async def root():
|
24 |
+
return {"message": "SentimentPro API is running!"}
|
25 |
+
|
26 |
+
@app.post("/predict/")
|
27 |
+
async def predict_sentiment(input: Input):
|
28 |
+
prediction = predict(input.text)
|
29 |
+
return {"text": input.text, "sentiment": prediction}
|