Created
June 20, 2021 21:56
-
-
Save nbertagnolli/806710563d5c55832a10ea0eb194d7ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI | |
from pydantic import BaseModel | |
# Initialize the FastAPI App | |
app = FastAPI() | |
# Create a Data Model so FastAPI can read the data from the request. | |
class Review(BaseModel): | |
text: str | |
@app.post("/review/predict") | |
async def movie_sentiment_prediction(review: Review): | |
"""Accept post requests and predicts positive or negative review""" | |
response = dict() | |
if "love" in review.text.lower(): | |
response["sentiment"] = "positive" | |
else: | |
response["sentiment"] = "negative" | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment