Skip to content

Commit

Permalink
Merge pull request microsoft#15 from TimPreble/master
Browse files Browse the repository at this point in the history
Allow No Name
  • Loading branch information
kraigb authored Jan 11, 2019
2 parents 4a221ac + 750939f commit 24f2fb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion hello_app/templates/hello_there.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
<title>Hello, Flask</title>
</head>
<body>
<span class="message">Hello there, {{ name }}!</span> It's {{ date.strftime("%A, %d %B, %Y at %X") }}.
{%if name %}
<span class="message">Hello there, {{ name }}!</span> It's {{ date.strftime("%A, %d %B, %Y at %X") }}.
{% else %}
<span class="message">What's your name? Provide it after /hello/ in the URL.</span>
{% endif %}
</body>
</html>
<!-- The above syntax makes use of jinja and it's documentation can be found over here http://jinja.pocoo.org/docs/2.10/templates/ -->
3 changes: 2 additions & 1 deletion hello_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def about():
def contact():
return render_template("contact.html")

@app.route("/hello")
@app.route("/hello/<name>")
def hello_there(name):
def hello_there(name = None):
return render_template(
"hello_there.html",
name=name,
Expand Down

0 comments on commit 24f2fb9

Please sign in to comment.