Framework Frankfurt, Germany

Deploy Flask on Nodion

Nodion recognizes Flask in your dependencies, installs them with its Python buildpack and starts Gunicorn with three workers on your app object. Migrations can run as a release step before each new version goes live, and the app runs in Frankfurt, next to a managed PostgreSQL database if you need one.

Deploy to Nodion ›

from 1 EUR / month

Up to 15 € credit when signing up

Detected by
Flask in your dependencies
Start
gunicorn app:app, 3 workers
Python
3.10 to 3.15, default 3.13
Region
EU Central (Frankfurt)

Deploy Flask step by step

  1. Add Gunicorn to your dependencies Nodion starts Gunicorn but does not install it, so list it next to Flask. Pin the Python version in .python-version, because a range in pyproject.toml picks the newest release. requirements.txt
    flask
    gunicorn
  2. Keep the app object in app.py Nodion takes the first of app.py, application.py and wsgi.py that contains Flask and runs gunicorn <file>:app with 3 workers on the PORT it sets. The object has to be called app. app.py
    from flask import Flask
    
    app = Flask(__name__)
    
    
    @app.get("/")
    def index():
        return "Hello from Frankfurt"
  3. Using an app factory? Add a web line With create_app() there is no module-level app to find, so tell Gunicorn to call the factory in a Procfile. The line replaces the default start command. Procfile
    web: gunicorn "myapp:create_app()" --bind 0.0.0.0:$PORT --workers 3
  4. Run migrations on every deploy With Flask-Migrate, a release: line runs flask db upgrade once per build, after the build and before the new version starts. If it fails, the deploy stops and the running version stays live. Procfile
    release: flask --app myapp db upgrade
  5. Create the app and the database Create an application from your repository in the region EU Central, then a PostgreSQL database in the same region, and attach it on the Environment tab: it arrives as DATABASE_URL on the next deploy. Set your SECRET_KEY as a secret variable, read it with os.environ, then push.

Good to know

  • DATABASE_URL and SQLAlchemyNodion's DATABASE_URL starts with postgres://, which SQLAlchemy 1.4 and newer do not accept. Replace the scheme before you pass it on: postgresql:// for psycopg2, postgresql+psycopg:// for psycopg 3.
  • Health checkTraffic switches once / answers with 2xx or 3xx, so a redirect to a login page is fine. If / returns 401 or 404, add a route such as /healthz and set it as the health check path in the app settings.
  • Celery and RQ workersAdd worker: celery -A myapp worker to the Procfile together with an explicit web: gunicorn app:app --bind 0.0.0.0:$PORT --workers 3; without a web: line the first Procfile entry other than release: becomes the default command. Then add a process named worker without a port on the Processes tab. Valkey in the same region gives you REDIS_URL.

What Nodion runs for you

  • Deploys without downtime Push to your branch and Nodion builds a new release. Traffic switches once the new instances answer their health check; a failed release leaves the running one in place. Apps with a local volume restart instead, because the disk belongs to one instance.
  • Databases next to the app Managed PostgreSQL, pgvector, MySQL, Valkey and ClickHouse in the same region. Attached databases arrive as DATABASE_URL, REDIS_URL or CLICKHOUSE_URL.
  • Previews per pull request Turn on previews and pull requests from your repository get their own app with its own URL and fresh, empty databases, created automatically or by hand. Forks and bot pull requests are skipped.
  • Workers, cron jobs and scaling Run workers as extra processes of the same app, schedule jobs on the Cron tab, and scale every process to up to 16 instances.
  • Release step With buildpacks, a Procfile release: line runs with every new build. Dockerfile apps, and redeploys or rollbacks to an earlier image, use a release command set on the app itself, which also takes precedence over the Procfile line. On static sites a release step runs in an image that holds only the built files.
  • Logs and metrics Build, release and runtime logs plus CPU, memory, disk and network metrics for every instance in the dashboard.
  • Domains and HTTPS A default hostname with HTTPS from the first deploy; your own domains get certificates automatically.

Further reading

Flask on Nodion: questions and answers

Why does my Flask app not start?

Usually Gunicorn is missing from your dependencies, the object is not called app, or the app is built in a factory. Add gunicorn, rename the object, or set a web: line that calls create_app().

Does Nodion use flask run or app.run()?

No. With Flask in your dependencies, Nodion starts Gunicorn. Flask's built-in server is meant for development, so keep app.run() under if __name__ == "__main__": for local use.

How many Gunicorn workers do I get?

Three by default. Set your own number with --workers in a web: line, and run more instances of the web process when one is not enough.

Where does my Flask app run?

In the EU Central region in Frankfurt, Germany. Build, registry, the app and its databases, volumes, buckets, logs and metrics stay in that region, and Nodion's API and control plane are hosted in Germany. Nodion GmbH is based in Stuttgart.

Can I use Flask in line with the GDPR?

Nodion provides the basis for it: Nodion GmbH is based in Stuttgart, Germany, in the Frankfurt region the app, its databases and volumes run in Germany, and you conclude the data processing agreement (DPA) under Art. 28 GDPR electronically in the dashboard. Whether your setup complies also depends on how you configure and use the app.

How much does it cost to run Flask on Nodion?

An app instance starts at 1 EUR per month. The setup in the cost box costs 3.50 EUR per month: App 2 EUR, PostgreSQL 1.50 EUR. Prices are net and billed per second, and you pick bigger sizes or more instances whenever you need them.

Can I use my own domain for my Flask app?

Yes. Every app gets a default hostname with HTTPS. Add your own domain on the app's Domains tab; the TLS certificate is issued and renewed automatically.

Give your agent a cloud.

Earn up to 15 € in credit when signing up.

Continue with GitHub

or with email

Stay in the loop.

Product news, no spam. Unsubscribe anytime.