Ship It to Production
A SaaS on your laptop isn't a business. This session takes it live: a real server, real payment keys, security hardening, and monitoring - the go-live checklist.
You've built the SaaS; now ship it. app.run() is the dev server - single-threaded, local only. In production, a Larz app is a standard WSGI application you serve with a real server, configure from the environment, secure, and monitor. This session is the go-live checklist that turns your project into something real users can pay for.
Run it for real
Serve the app with gunicorn (or similar), configure secrets from the environment, and put it behind a reverse proxy over HTTPS.
pip install larz gunicorn
gunicorn -w 4 -c deploy/gunicorn.conf.py app:app
# config from the environment, never hard-coded:
import os, larz.ops as ops
ops.load_env('.env')
app = Larz(secret=os.environ['SECRET'])| Dev | Production |
|---|---|
| app.run() | gunicorn with multiple workers |
| Keyless mock provider | Real provider keys (Stripe/Paddle/...) |
| Secrets in code | Secrets from env vars |
| http://localhost | HTTPS behind nginx/Caddy |
The repo ships a Dockerfile, systemd unit, nginx config and gunicorn config to make this straightforward.
Go live safely
Flip payments to real, verify webhooks, and turn on the security middleware before you take money.
import larz.security as security
app.use(security.bot_filter())
app.use(security.RateLimiter(limit=120, window=60))
app.use(security.csrf_protect(secret=os.environ['SECRET']))
ops.enable(app) # adds /healthz + /metrics for monitoringShip it
- Serve with gunicorn - not app.run(); scale with workers.
- Config from env - secrets and keys never in code.
- Harden - rate limiter, bot filter, CSRF, HTTPS.
- Monitor - /healthz + /metrics; then launch. โก
๐ฏ Key takeaways
- app.run() is dev-only; in production serve the WSGI app with gunicorn and scale with workers.
- Configure secrets and keys from the environment, never in code; run over HTTPS behind a proxy.
- Go live safely: real provider + verified webhooks, rate limiter + bot filter + CSRF, and monitoring.
- Test a payment in the provider's test mode before flipping to live - then ship it.
Frequently asked
Why can't I just use app.run() in production?
app.run() is a development server: it's single-threaded, unoptimised, and not built to handle real traffic or be exposed to the internet safely. In production you serve the app with a proper WSGI server like gunicorn, which runs multiple worker processes for concurrency and is designed for load, usually behind a reverse proxy (nginx/Caddy) that handles HTTPS. Larz is a standard WSGI app, so this is straightforward and the repo includes ready-made deploy configs. Using app.run() live would be slow, fragile and insecure - it's purely for local development.
What's the most important thing to get right before taking real money?
Several things are non-negotiable, but if you must prioritise: use a strong secret and real provider keys from environment variables (never committed), run over HTTPS, and verify that payments and webhooks work correctly in the provider's test mode before switching to live - so you know entitlements are granted and invoices recorded properly. Right alongside that, turn on the security middleware (rate limiting, bot filter, CSRF) and make sure your database path is durable and backed up. The full go-live checklist in this session ties these together; skipping the payment-testing or the secrets/HTTPS basics is where real money-handling goes wrong.
You've finished the Build a SaaS with Larz sessions
Now lock it in with the coursework.
Do the assignments โ