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
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 theconfig.py
file replacingAPI_KEY_Public.API_KEY_Private
with your downloaded API Key andhttps://app.modzy.com/api
with your Modzy instance URL. - now type
export FLASK_APP=demo_site.py
(orset FLASK_APP=demo_site.py
if on Windows) - Finally, start Flask with the command
flask run
- Type
- 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