Deploying a Python app with Flask

Flask is a popular micro-framework for building Python web apps. It requires minimal setup and is easy to get started with. Structure provides first-class support for creating and deploying Flask apps. Here, we'll go over what project files are required to deploy a minimal, but production-ready Flask app on Structure.
app.py
requirements.txt

app.py

Your application file should be called `app.py`, with your Flask application variable also named `app`. Here's an example:
# File: app.py

from flask import *
app = Flask(__name__)

@app.route('/')
def index():
    return 'Hello, world!'        
Note: You don't need to include an app.run() statement. Structure will automatically handle that for you when you deploy it.
That's it for your app.py file!

requirements.txt

For our Flask app to run, we'll need the Flask framework itself! We can define this dependency (and others) in a text file called `requirements.txt`. You can list all your pip dependencies your app needs to run here, along with its version number. When Structure runs your app, it'll use pip (the Python package manager) to install and load all your dependenices.
# File: requirements.txt

flask==0.12.2  

Moving forward

From here, you're ready to deploy to production! First, create Flask app on Structure (either through the web interface, or by running structure create through the CLI). Let's assume your app is named "hello-world". Now, navigate to your project directory and run:
$ structure deploy hello-world
Note: Sometimes, like when you change your `requirements.txt` file, you'll need to reload your app when you deploy. You can run `structure restart --app APP-NAME` to do this.