Web App Deployment

From Laptop to Internet: How Deployment Works

25 Min.

On your laptop, your app runs with python run.py and only you can see it. Deploying means running it on a computer that is always on, reachable at a domain, over HTTPS, with real data, safely.

The pieces of a live web app

Piece Job Examples
Hosting runs your code 24/7 Render, Railway, Fly.io, a VPS, AWS
App server serves Python requests in production Gunicorn (Flask/Django), Uvicorn (FastAPI)
Database stores data permanently managed PostgreSQL
Static/media files images, CSS, uploads the app, a CDN, S3 or R2
Domain + DNS yourapp.com → your host Cloudflare, Namecheap
TLS certificate HTTPS Let's Encrypt (usually automatic)
Environment variables secrets and settings the platform's dashboard
Monitoring know when it breaks health checks, logs, Sentry

Hosting options

  • Platform as a Service (PaaS): Render, Railway, Heroku, Fly.io. You push code; they build and run it. Least work, slightly higher cost. Best for most small apps.
  • Virtual private server (VPS): Hetzner, DigitalOcean. A Linux machine you manage yourself. Cheapest for the power, but you handle security, updates and backups (see Linux System Administration).
  • Serverless/edge: Vercel, Netlify, Cloudflare. Ideal for static sites and frontends; backends run as functions.
  • Cloud (AWS, GCP, Azure): everything, at the cost of complexity.

The development vs production gap

Development Production
debug=True debug off (debug pages leak code and allow code execution)
SQLite file managed PostgreSQL
flask run dev server Gunicorn with several workers
secrets in .env secrets in the platform's environment settings
errors on screen errors in logs and error tracking

The twelve-factor ideas that matter most

  1. Config in the environment, not in code.
  2. Dependencies declared (requirements.txt pinned).
  3. Stateless processes: do not store uploads or sessions on the server's disk if you might run more than one instance or redeploy (disks on many platforms are wiped on deploy).
  4. Logs to stdout: the platform collects them.
  5. Dev/prod parity: keep environments as similar as possible.

Check yourself

  • Why must debug mode be off in production?
  • What is the trade-off between a PaaS and a VPS?
  • Why should uploads not live on a PaaS server's local disk?

Ihr Fortschritt wird nur in diesem Browser gespeichert.

Zur Prüfung einreichen (10 Punkte)