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.

74 lines
2.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# ![](https://ga-dash.s3.amazonaws.com/production/assets/logo-9f88ae6c9c3871690e33280fcf557f33.png) 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
<!--- Provide a breakdown of what will happen in this lesson. --->
| Time | Activity | Purpose |
| --- | --- | --- |
| 0:00 - 0:02 | [Welcome](#activity-welcome-2-min) | Introduce the lessons objectives and agenda. |
| 0:02 - 0:30 | [Variables](#activity-variables-28-min) | Import variables in the context of a Flask app. |
| 0:30 - 0:57 | [Routes](#activity-routes-27-min) | Cover what routes are and how to make them. |
| 0:57 - 0:60 | [Summary](#activity-summary-3-min) | 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 lessons 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.