Week 1: Hello Flask
This week you build your first Flask app — a Python program that serves web pages at different URLs. Every page is generated by a Python function. Welcome to the dynamic web.
Build means build. Open your repo, type the code, run it, see it in a browser. Reading this page is step zero, not the finish line.
Why Flask?
At the end of this course, you need to be able to build a working web application. That's table stakes — the minimum skill set you need before you can even start thinking about your own project.
Flask is the tool we use to get there. This sequence teaches it one piece at a time, so that when you sit down to build something real, you've already done each piece before. Separately. In order. With bumpers.
What you already know
- Basic Python: functions, strings,
return,import - You've used
import randomandfrom random import randint
What's new this week
- The Flask library and the
Flaskclass - The
appobject - Route decorators (
@app.route) - Route variables (
<name>) render_template()and thetemplates/folder- Running a development server with
flask run --debug
The assignment
By the end of this week you'll have a multi-route Flask app where each URL serves a different HTML page from the templates/ folder. This is the skeleton that every Flask project is built on — including the one you'll build on your own in Week 6.
Read the pages in this section in order. Each one builds on the last.