fastapi-sentiment-routes
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 fastapi_sentiment import sentiment_analysis | |
from fastapi_sentiment.models import ( | |
SentimentDocument, | |
SentimentScoring, | |
Message | |
) | |
app = FastAPI() | |
@app.get("/", response_model=Message, status_code=200) | |
def read_root() -> Message: | |
return { | |
'message': 'Hello World' | |
} | |
@app.get("/health", response_model=Message, status_code=200) | |
async def get_health() -> Message: | |
return { | |
'message': 'Still kicking' | |
} | |
@app.post("/sentiment", response_model=SentimentScoring, status_code=200) | |
async def get_sentiment(document: SentimentDocument) -> SentimentScoring: | |
return sentiment_analysis.get_sentiment(document.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment