Phase 9 - Deployment
Deployment is where many Flask apps break because development and production environments behave differently.
This phase teaches a practical deployment mental model:
- your Flask app is a WSGI app
- Gunicorn runs it with multiple workers
- Nginx sits in front as a reverse proxy
- configuration comes from environment variables
You’ll learn
Section titled “You’ll learn”- Preparing for production
- Environment variables and
.env - Gunicorn
- Nginx as reverse proxy
- Dockerizing a Flask app
- Deploying to Render
- Deploying to PythonAnywhere
- Deploying to AWS EC2
Phase checklist
Section titled “Phase checklist”- Preparing for Production
- Environment Variables (.env)
- Gunicorn Web Server
- Using Nginx as Reverse Proxy
- Dockerizing Flask App
- Deploying to Render
- Deploying to PythonAnywhere
- Deploying to AWS EC2
The phase at a glance
Section titled “The phase at a glance”This phase exists to run the app somewhere other than your laptop. It assumes an application you are ready to expose, and once it is done you can build all of it, running on a public server.
flowchart TD
subgraph G0["Getting production-ready"]
N0_0["Preparing for Production"]
N0_1["Environment Variables (.env)"]
N0_2["Gunicorn Web Server"]
end
subgraph G1["Serving it properly"]
N1_0["Using Nginx as Reverse Proxy"]
N1_1["Dockerizing Flask App"]
end
N0_2 --> N1_0
subgraph G2["Somewhere to put it"]
N2_0["Deploying to Render"]
N2_1["Deploying to PythonAnywhere"]
N2_2["Deploying to AWS EC2"]
end
N1_1 --> N2_0
Where this sits in the track
Section titled “Where this sits in the track”The pages, in reading order
Section titled “The pages, in reading order”| # | page |
|---|---|
| 1 | Preparing for Production |
| 2 | Environment Variables (.env) |
| 3 | Gunicorn Web Server |
| 4 | Using Nginx as Reverse Proxy |
| 5 | Dockerizing Flask App |
| 6 | Deploying to Render |
| 7 | Deploying to PythonAnywhere |
| 8 | Deploying to AWS EC2 |
8 pages. They are ordered so that each one only uses ideas from the pages above it — reading out of order mostly works, but the examples assume what came before.
Check yourself
Section titled “Check yourself”-
Why is the Flask development server not used in production?
Werkzeug prints the warning on every start. Gunicorn or uWSGI runs the app, and Nginx usually sits in front of it.
pch.quizShowAnswer
B — it is single-process by default, unhardened, and prints a warning saying so — Werkzeug prints the warning on every start. Gunicorn or uWSGI runs the app, and Nginx usually sits in front of it.
-
Why do Environment Variables come before any hosting page in this phase?
Render, PythonAnywhere, Docker and EC2 differ in how you supply them, not in whether you need them. Learning the principle once makes each host a detail.
pch.quizShowAnswer
B — every deployment target needs the same thing: configuration and secrets supplied from outside the code — Render, PythonAnywhere, Docker and EC2 differ in how you supply them, not in whether you need them. Learning the principle once makes each host a detail.
-
What do the phase overview pages give you that the individual pages do not?
Each overview lists its pages in sidebar order and names the phase's prerequisites and outcome, so you can tell whether you are ready for it.
pch.quizShowAnswer
B — the reading order, what the phase assumes, and what you can build once it is done — Each overview lists its pages in sidebar order and names the phase's prerequisites and outcome, so you can tell whether you are ready for it.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading