Skip to content

Commit 24f2fb9

Browse files
authored
Merge pull request microsoft#15 from TimPreble/master
Allow No Name
2 parents 4a221ac + 750939f commit 24f2fb9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

hello_app/templates/hello_there.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
<title>Hello, Flask</title>
77
</head>
88
<body>
9-
<span class="message">Hello there, {{ name }}!</span> It's {{ date.strftime("%A, %d %B, %Y at %X") }}.
9+
{%if name %}
10+
<span class="message">Hello there, {{ name }}!</span> It's {{ date.strftime("%A, %d %B, %Y at %X") }}.
11+
{% else %}
12+
<span class="message">What's your name? Provide it after /hello/ in the URL.</span>
13+
{% endif %}
1014
</body>
1115
</html>
1216
<!-- The above syntax makes use of jinja and it's documentation can be found over here http://jinja.pocoo.org/docs/2.10/templates/ -->

hello_app/views.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ def about():
1414
def contact():
1515
return render_template("contact.html")
1616

17+
@app.route("/hello")
1718
@app.route("/hello/<name>")
18-
def hello_there(name):
19+
def hello_there(name = None):
1920
return render_template(
2021
"hello_there.html",
2122
name=name,

0 commit comments

Comments
 (0)