← Flask learning path
Flask · Module 10 of 10

Deploying Flask

Run Flask in production with gunicorn, Docker and cloud hosts.

📖 Key ideas

  1. Use gunicorn: gunicorn -w 4 "app:create_app()".
  2. Put Nginx in front for HTTPS and static files.
  3. Keep secrets in environment variables (.env never in Git).
  4. Containerise with Docker; deploy to Render, Railway, AWS or Cloud Run.
  5. Add logging and error monitoring (Sentry).
💡 Real-life example: gunicorn is a team of waiters; Nginx is the doorman managing who enters.
gunicornProduction WSGI server
NginxReverse proxy and web server
-w 4Number of worker processes
SentryError monitoring service