Skip to content

Commit 320e92e

Browse files
committed
Small updates
1 parent a2b4ca8 commit 320e92e

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

en/images/.DS_Store

0 Bytes
Binary file not shown.

en/images/flask-app-link.png

88.9 KB
Loading

en/images/flask-hello-paul.png

83 KB
Loading

en/step_6.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
Websites like Facebook, YouTube and BBC News have dynamic content: these websites show different content within the same template.
44

5-
Now you will create a new route on your website so that when you go to `http://127.0.0.1/hello/name`, the page will show you a personal greeting. So for example, `/hello/Dana/` displays 'Hello Dana!'.
6-
5+
Now you will create a new route on your website so that the page will show you a personalised greeting.
76
--- task ---
87

9-
Add a new route to your application:
8+
Open `app.py` and add a new route to your application:
109

1110
--- code ---
1211
---
@@ -28,7 +27,7 @@ def hello(name):
2827

2928
--- task ---
3029

31-
Create a new HTML template called `page.html`, and add the following HTML code to it:
30+
Create a new HTML template in the templates folder called `page.html`, and add the following HTML code to it:
3231

3332
--- code ---
3433
---
@@ -64,7 +63,7 @@ Open your `index.html` template and add a link to the hello page under the headi
6463
language: html
6564
line_numbers: true
6665
line_number_start: 6
67-
line_higlights: 7
66+
line_highlights: 7
6867
---
6968
<h1>My website</h1>
7069
<a href="/hello/paul">Hi Paul</a>
@@ -85,7 +84,7 @@ Save the changes to `index.html`, and then open `localhost:5000` to see the upda
8584
title: How does this route work?
8685
---
8786

88-
- `@app.route('/hello/<name>')`: the `<name>` part means it passes the name into the `hello` function as a variable called `name`.
87+
- `@app.route('/hello/<name>')`: the `<name>` part passes the text written in the URL into the `hello` function as a variable called `name`.
8988
- `def hello(name)`: this is the function that determines what content is shown. Here, the function takes the given name as a parameter.
9089
- `return render_template('page.html', name=name)`: this code looks up the template `page.html` and passes in the variable `name` from the URL so that the template can use it.
9190

@@ -96,8 +95,8 @@ Flask uses `jinja`, a Python library for rendering templates. Look at this code
9695
<h1>Hello {{ name }}!</h1>
9796
```
9897

99-
This code tells the template to render the variable `name` that was passed in the route function `hello`.
98+
This code tells the template to use the variable `name` that was passed in the route function `hello`.
10099

101-
Visiting `127.0.0.1:5000/hello/` without a name creates an error. Try to think of a way to prevent this error.
100+
Visiting `localhost:5000/hello/` without a name creates an error.
102101

103102
--- /collapse ---

0 commit comments

Comments
 (0)