Modzy in a Flask app Quickstart

How to create a simple web app to run a Modzy hosted model from scratch.

In this tutorial we will walk through creating a simple web application with Python and the Flask framework backed by AI/ML Algorithms from Modzy.

Modzy Flask Quickstart tutorial

  • Download the project code.
  • Install Python
    • If you already have Python installed, you may skip this step.
    • If you don't have Python installed, install it now. You can download an installer from the Python official website or on a Mac you can install with Homebrew.
    • To verify your Python installation type python3 into your terminal window.
  • Install Flask
    • If you already have Flask installed, you may skip this step.
    • Verify that your terminal is in the Modzy Flask Template folder.
    • First we will create a virtual environment to contain this project. Enter python3 -m venv venv into the terminal and press enter.
    • After the command completes, type source venv/bin/activate and press enter.
    • Now type pip install flask flask-wtf and hit enter.
  • Install Modzy-SDK and configure your API url and key
    • Type pip install modzy-sdk to your terminal and press enter.
    • Retrieve your Modzy API key. It is a good idea to create a new project and use the project's API key to better organize and monitor activity related to this application.
    • If you are using Linux or Mac, type export API_KEY=yourAPI_key, export API_URL=yourAPI_URL and hit enter. If using a Windows terminal, set API_KEY=yourAPI_key, set API_URL=yourAPI_URL. Alternatively, you may edit the config.py file replacing API_KEY_Public.API_KEY_Private with your downloaded API Key and https://app.modzy.com/api with your Modzy instance URL.
    • now type export FLASK_APP=demo_site.py (or set FLASK_APP=demo_site.py if on Windows)
    • Finally, start Flask with the command flask run
  • Open your new Web server!

  • Use the application
    • Type any text into the 'My Text' box and hit Analyze.
    • A few seconds later, the results of the sentiment analysis will be displayed!

You're done! Now click Next Steps and have some fun – or for a more in-depth tutorial on how Modzy works with Flask, walk through the Modzy in a Flask app Tutorial