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.
- Download or clone the Modzy Flask Template from Github: https://github.com/modzy/modzy_flask_template
- Open a terminal window and navigate to the Modzy Flask Template directory you just downloaded.
- 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
python3into 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 venvinto the terminal and press enter.
- After the command completes, type
source venv/bin/activateand press enter.
- Now type
pip install flask flask-wtfand hit enter.
- Install Modzy-SDK and configure your API url and key
pip install modzy-sdkto 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_URL=yourAPI_URLand hit enter. If using a Windows terminal,
set API_URL=yourAPI_URL. Alternatively, you may edit the
API_KEY_Public.API_KEY_Privatewith your downloaded API Key and
https://app.modzy.com/apiwith your Modzy instance URL.
- now type
set FLASK_APP=demo_site.pyif on Windows)
- Finally, start Flask with the command
- Open your new Web server!
- Using a web browser of your choice, navigate to http://127.0.0.1:5000/
- You should see this in your brower:
- 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
Updated 6 months ago