Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 67,636 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."