Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Flask Basics Templates and Static Files Simple Template

Flash Basics Challenge Task 3 of 3

Where is the problem? If l put

return render_template("hello.html", {{name}}=”name”)

At the end TASK ONE IS NO LONGER PASSING

Please assist

flask_app.py
from flask import Flask
from flask import render_template

app = Flask(__name__)

@app.route('/hello/<name>')
def hello(name="Treehouse"):
    return render_template("hello.html", name='name')
templates/hello.html
<!doctype html>
<html>
<head><title>Hello!</title></head>
<body>
<h1>Howdy!</h1>
</body>
</html>

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Here is your whole code with corrections:

flask_app.py

from flask import Flask
from flask import render_template

app = Flask(__name__)

@app.route('/hello/<name>')
def hello(name="Treehouse"):
    return render_template("hello.html", name=name) #<-- removed quotes from name

templates/hello.html

<!doctype html>
<html>
<head><title>Hello!</title></head>
<body>
<h1>Howdy! {{ name }}</h1> {# added name #}
</body>
</html>
Sage Elliott
Sage Elliott
30,003 Points

You need to assign the variable name, so you do not need those quotations around the name = 'name'. Should look like this:

flask_app.py

return render_template("hello.html", name=name)

Inside your template file pass the name variable next to "howdy!". In flask you use double curly brackets{{}} to print the variables value.

templates/hello.html

<h1>Howdy! {{ name }} </h1>

I hope this helps! :)

Thanx it is still giving me problems kindly revise my whole code the TASK is "Pass the name argument to the template. Print the name variable in the <h1> in the template."

Sage Elliott
Sage Elliott
30,003 Points

Woops my second code snippet was messed up! In you template add {{ name }} after howdy in the h1 tags

Sage Elliott
Sage Elliott
30,003 Points

I fixed in original post:

<h1>Howdy! {{ name }} </h1>
Seth Reece
Seth Reece
32,867 Points

In flask_app.py change name='name' to name = name. In hello.html put {{ name }} After Howdy!

Thanx it is still giving me problems kindly revise my whole code and write it below. The TASK is "Pass the name argument to the template. Print the name variable in the in the template."