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.

michaelangelo owildeberry
18,172 PointsPass the name argument to the template. Print the name variable in the <h1> in the template.
"Didn't find the passed-in name in the template." Please help =)
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')
return 'Hello {}'.format(name)
<!doctype html>
<html>
<head><title>Hello!</title></head>
<body>
<h1>Howdy!</h1>
</body>
</html>
5 Answers

Kenneth Love
Treehouse Guest TeacherYou don't have a {{ name }}
in the template and you're always hardcoding name
to the string "name"
when you render the template.

Erion Vlada
13,496 PointsThis will work, your two errors are, like Kenneth Love said, you used name = 'name'
instead of name = name
and you didn't put {{name}}
in your html template so that value is actually used.
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)

Ruby R
1,086 PointsI got bummer - Dint find the passind-in name in the template.
Code:
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route('/hello/<name>')
def hello(name='Treehouse'):
context={'name':name}
return render_template("hello.html", **context)
<!doctype html>
<html>
<head><title>Hello {{name}}!</title></head>
<body>
<h1>{{name}}</h1>
</body>
</html>

Ron Fisher
5,752 PointsMichaelangelo,
I haven't taken this course but the web info shows you have to have a placeholder for the incoming variable. It shows something like {{ name }}.
Ron

michaelangelo owildeberry
18,172 PointsRight =) I am so used to only editing one file that html escapes my grasp.