Flask Apps§

To run your Flask apps in Unit:

  1. Install Unit with the appropriate Python language module version.

  2. If you haven’t already done so, create your Flask app.

  3. Prepare Unit configuration for your update. To obtain an initial template, query the control API:

    # curl --unix-socket /path/to/control.unit.sock \
           http://localhost/config/ > config.json


    Control socket path may vary; run unitd --help or see Startup for details.

    This creates a JSON file with Unit’s current settings. Add a listener for your project in listeners and point it to your project’s and virtual environment in applications:

        "listeners": {
            "*:8080": {
                "pass": "/applications/flask_app"
        "applications": {
            "flask_app": {
                "type": "python 3",
                "path": "/home/flask/flask_app/",
                "home": "/home/flask/venv/",
                "module": "wsgi"

    For details, see Python app settings.

  4. Upload the updated configuration:

    # curl -X PUT --data-binary @config.json --unix-socket \
           /path/to/control.unit.sock http://localhost/config

    After a successful update, your app should be available on the listener’s IP address and port:

    $ curl