sentiment_classifier.api package

We use Flask to write the API and we are using the factory pattern to create the Flask application. This is an elegant method that allows us to separate the code for the app creation, and register all the blueprints in one place.

The factory runs the following steps:

  • Create the Flask object
  • Load the ML models and attach them
  • Register the index blueprint
sentiment_classifier.api.create_app(model_filepath)[source]

Flask app factory method

Returns:The created Flask application

Submodules

sentiment_classifier.api.index module

Index blueprint for the Flask API. This blueprint hosts the code for classifying a sequence.

sentiment_classifier.api.index.classify()[source]

api method for predicting the sentiment on a given sequence.

Returns:A json with text, sentiment and score
sentiment_classifier.api.index.index()[source]

api status check method.

Returns:json

sentiment_classifier.api.wsgi module