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.

Ollie Webster
5,035 PointsCannot render template.
I have tried combinations of adding/removing the @app.route('/')
, and also adding and removing return` in front of
render_template```
The Code Challenge still says that it didn't get the template.
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route('/hello/<name>')
@app.route('/')
def hello(name="Treehouse"):
return 'Hello {}'.format(name)
return render_template("hello.html")
<!doctype html>
<html>
<head><title>Hello!</title></head>
<body>
<h1>Howdy!</h1>
</body>
</html>
1 Answer

Alexander Davison
65,454 PointsYou only need to return render_template("hello.html")
. You are returning 'Hello {}'.format(name)
before it, and when you return anything from a function, the function terminates. Thus you only return 'Hello {}'.format(name)
, and not the template.
Ollie Webster
5,035 PointsOllie Webster
5,035 PointsThanks! I just worked this out. To me this seems as an example of the Challenge trying to break up an overall goal into steps that are too small and therefore difficult to put into context of what is trying to be achieved. For example, if they just removed this second part of the challenge and skipped to the third part where it wanted you to pass
name
tohello.html
and deal with this inhello()
, I'm sure I would have automatically removed the offending code.