Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,17 @@
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
| 2 |
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
|
| 3 |
|
| 4 |
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
@app.get("/")
|
| 7 |
def greet_json():
|
| 8 |
return {"Hello": "World!"}
|
| 9 |
|
| 10 |
@app.post("/sentiment")
|
| 11 |
-
def sentiment_analysis(
|
| 12 |
analyzer = SentimentIntensityAnalyzer()
|
| 13 |
-
return analyzer.polarity_scores(
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
|
| 4 |
|
| 5 |
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
class SentimentRequest(BaseModel):
|
| 8 |
+
message: str
|
| 9 |
|
| 10 |
@app.get("/")
|
| 11 |
def greet_json():
|
| 12 |
return {"Hello": "World!"}
|
| 13 |
|
| 14 |
@app.post("/sentiment")
|
| 15 |
+
def sentiment_analysis(payload: SentimentRequest):
|
| 16 |
analyzer = SentimentIntensityAnalyzer()
|
| 17 |
+
return analyzer.polarity_scores(payload.message)
|