> ## Documentation Index
> Fetch the complete documentation index at: https://help.noxity.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy Flask

> Run a Flask app on the Python Selector. One-line passenger_wsgi.py, environment variables, the works.

Flask is the smallest viable WSGI app. One file imports your `app` object and aliases it as `application`.

For the underlying tool, see [Python](/web-hosting/virtual-containers/python).

## Before you begin

* A Python app created in cPanel, version 3.10 or 3.11.
* The app root contains your Flask code (e.g. `app.py` defining `app = Flask(__name__)`).
* A `requirements.txt` listing Flask and your other packages.

## Wire up Passenger

<Steps>
  <Step title="Create passenger_wsgi.py">
    ```python passenger_wsgi.py theme={}
    from app import app as application
    ```

    If your Flask app object is named differently (e.g. `flask_app = Flask(__name__)`), alias it: `from app import flask_app as application`.
  </Step>

  <Step title="Install dependencies">
    Click **Run Pip Install** in the cPanel app management page.
  </Step>

  <Step title="Restart">
    Click **Restart**.
  </Step>
</Steps>

## Strip the dev server

Most Flask tutorials end with:

```python theme={}
if __name__ == '__main__':
    app.run(debug=True)
```

Leave the `if __name__` block, or remove it. It's never executed under Passenger anyway. Just don't call `app.run()` at module top level.

## Common issues

<AccordionGroup>
  <Accordion title="500: 'did not provide an application callable'">
    `passenger_wsgi.py` doesn't expose `application`. Check the import line: `from app import app as application`.
  </Accordion>

  <Accordion title="ImportError on a package you just pip-installed">
    Pip ran against the system Python, not the per-app virtualenv. Install via the cPanel **Run Pip Install** button, or activate the env first in SSH.
  </Accordion>

  <Accordion title="Changes don't show up after editing the code">
    Passenger caches the loaded modules. Restart with the **Restart** button or `touch tmp/restart.txt`.
  </Accordion>
</AccordionGroup>

## Need a hand?

<CardGroup cols={2}>
  <Card title="Open a ticket" icon="life-ring" href="https://members.noxity.io/submitticket.php">
    Best for anything that needs an account check or a config change on our end.
  </Card>

  <Card title="Live chat" icon="messages" href="https://noxity.io/contact">
    Faster for quick questions during business hours.
  </Card>
</CardGroup>
