Spaces:
Sleeping
Sleeping
Rename app.py to main.py
Browse files- app.py → main.py +18 -19
app.py → main.py
RENAMED
|
@@ -1,19 +1,18 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
-
from pydantic import BaseModel
|
| 3 |
-
from backend import predict
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
return {"text": input.text, "sentiment": prediction}
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
from backend import predict
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class Input(BaseModel):
|
| 9 |
+
text: str
|
| 10 |
+
|
| 11 |
+
@app.get("/")
|
| 12 |
+
async def root():
|
| 13 |
+
return {"message": "Sentiment Analysis API is running!"}
|
| 14 |
+
|
| 15 |
+
@app.post("/predict/")
|
| 16 |
+
async def predict_sentiment(input: Input):
|
| 17 |
+
prediction = predict(input.text)
|
| 18 |
+
return {"text": input.text, "sentiment": prediction}
|
|
|