Flask is a Python microframework for building web sites with minimal overhead. Think of it as a lightweight version of Django with fewer features, but better speed. Flask is supported on v6+ platforms using Passenger.
All steps are done from the terminal. While it may be possible to deploy a Flask application without using terminal, it is strongly recommended for ease.
- Prerequisite: create a Passenger-compatible filesystem layout
- Change directories to the base, we’ll name the base directory
- Optional: determine which Python version to use for Flask using pyenv
- Install flask using pip:
pip install flask
- Create a Passenger startup file to run Flask as a Python WSGI application:
from flask import Flask application = Flask(__name__) @application.route("/") def hello(): return "Hello World!" if __name__ == "__main__": application.run()
- Of importance, this example is identical to the Flask “Hello World!” example with a minor change:
appis renamed to
applicationto comply with Passenger. Passenger will always look for an instance variable named
applicationto run the application.
public/to a subdomain within the control panel under Web > Subdomains
- Access your subdomain running Flask
Restarting a Flask app
Since Flask runs using Passenger, it uses the same restart method as any Passenger-backed app.
- Explore Flask eBook
- Flask documentation
- Django vs Flask vs Pyramid
- Flask demo running on a v6 account