Skip to content

Commit 1a68425

Browse files
committed
clarificatons added
1 parent 8af8b03 commit 1a68425

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

flask/part3_templates/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ Now you'll see how to write 100 web pages with no actual HTML files. Well, excep
169169

170170
We are building on the [ex2-app](ex2-app) example app, discussed above.
171171

172-
Now, in the third version — the [ex3-app](ex3-app) example app — we will make our two templates much more useful by enabling them to use data read from a separate file, *data.py*. That file contains information (name, ID, address, etc.) about 100 students (not real people).
172+
Now, in the third version — the [ex3-app](ex3-app) example app — we will make our two templates much more useful by enabling them to use data from a separate file, *data.py*. That file contains a bunch of information (name, ID, address, etc.) about 100 students (not real people).
173173

174-
Instead of working with the whole file while working out the bugs, the *students3.py* file uses just two records from the dataset. In addition to the list named DATA, two new functions have been added. These functions are outside the routes, but they are called *in* the routes.
174+
Instead of working with the whole file while working out the bugs, the *students3.py* file uses just two records from the dataset. In addition to the **list** named `DATA`, two new functions have been added. These functions are outside the routes, but they are called *in* the routes.
175175

176176
```
177177
get_all_students() --> used in index()
@@ -183,17 +183,24 @@ gets the following details about ONE student: name, address, photo
183183

184184
* We still have only two routes in our Flask app.
185185
* We still have only two templates, plus the base template.
186-
* We have added data about two students in *students3.py*.
186+
* We have **added** data about two students in *students3.py*.
187187
* We have added two new Python functions (no Flask code in these):
188-
* get_all_students()
189-
* get_student()
188+
* `get_all_students()`
189+
* `get_student()`
190190

191-
The goal is to provide a list of all students (last names only) with an `<a href="">` that contains the student's ID number. When we click any student's name, a new URL opens, showing us details and a photo for just that one student.
191+
The goal is to provide a list of all students (last names only), each with an `<a href="">` that contains the student's ID number.
192+
193+
1. When we click any student's name, we send a new URL to the browser.
194+
2. In the Flask app, that URL runs the route decorater: `@app.route('/student/<idnum>')`
195+
2. That causes the Flask route function `student(idnum)` to run.
196+
3. That function gets the name, photo, and address for the specific student with that ID number in `DATA` &mdash; a Python list of dictionaries you can see in lines 8-11 in [students3.py](ex3-app/students3.py).
192197

193198
The ID number is used in the link because it is sure to be unique, unlike a name. We have been using a number in the route `@app.route('/student/<idnum>')` all along.
194199

195200
The complete code for this app is in the folder [ex3-app](ex3-app).
196201

202+
**The complete dataset of 100 students** is used in in [students4.py](ex3-app/students4.py).
203+
197204
**To run the final, complete app** in your activated virtualenv, `cd` into the `ex3-app` directory and type this at the bash prompt (`$`) in Terminal:
198205

199206
```bash

0 commit comments

Comments
 (0)