jflo commited on
Commit
83e8c6c
·
1 Parent(s): ec02dbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
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(message: str):
12
  analyzer = SentimentIntensityAnalyzer()
13
- return analyzer.polarity_scores("This is a positive message")
 
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)