You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
5 years ago | |
|---|---|---|
| .. | ||
| 04-routing-slides.md | 5 years ago | |
| 04-routing-slides.md.html | 5 years ago | |
| 04-routing-slides.md.pdf | 5 years ago | |
| README.md | 5 years ago | |
README.md
Variables and Routing in Flask
Overview
The first half of this lesson focuses on variables in Flask — pulling them from the file itself, other Python files, and then other files of different types. The second half of the lesson covers creating and navigating to routes and variable routes.
Learning Objectives
In this lesson, students will:
- Display variables on a webpage.
- Create a route in Flask.
Duration
60 minutes
Suggested Agenda
| Time | Activity | Purpose |
|---|---|---|
| 0:00 - 0:02 | Welcome | Introduce the lesson’s objectives and agenda. |
| 0:02 - 0:30 | Variables | Import variables in the context of a Flask app. |
| 0:30 - 0:57 | Routes | Cover what routes are and how to make them. |
| 0:57 - 0:60 | Summary | Wrap up the learning and share next steps. |
Materials and Preparation
- If your class is picking things up quickly, you might want to, in advance, come up with a few exercises that combine routing with variables.
Differentiation and Extensions
- Students having a more difficult time with this might want to revisit the lecture on functions and variables.
- For students who grasp it easily, have them experiment with putting routes and the different variable methods together and see what happens.
Lesson Procedure
Activity: Welcome (2 minutes)
Introduce the lesson’s objectives and agenda.
Activity: Variables (28 minutes)
Import variables in the context of a Flask app.
Teaching Tips:
- Go over when each method is best. Recommend to students that reading in a file from another Python file is more pythonic and, ultimately, less code
- If you have time, give students leeway to practice multiple things multiple ways.
Activity: Routes (27 minutes)
Cover what routes are and how to make them.
Teaching Tips:
- Add more exercises wherever possible. Give more difficult programs to print and display on each route.
- If a student asks why only the main page has styling, table it! Templates are next.
Activity: Summary (3 minutes)
Wrap up the learning and share next steps.