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 trialKen Tuntiansin
1,523 PointsFlask template block challenge 1 of 6. I'm not quite sure what is wrong.
Add two blocks to the "layout.html" template. Add a block named title around the content of the <title> tag. Add a block named content inside the <body> tag.
I'm getting "Didn't find the right number of endblocks" as response even though there are two blocks.
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
<!doctype html>
<html>
<head><title>Homepage</title></head>
<body>
<h1>Smells Like Bakin'!</h1>
<p>Welcome to my bakery web site!</p>
</body>
</html>
<!doctype html>
<html>
<head><title>{% block title %}Smells Like Bakin'{% endblock title %}</title></head>
<body>
{% block content %}{% endblock content %}
</body>
</html>
2 Answers
Carlos Federico Puebla Larregle
21,074 PointsThere's no need of put which block is ending:
<!doctype html>
<html>
<head><title>{% block title %}Smells Like Bakin'{% endblock %}</title></head>
<body>
{% block content %}{% endblock %}
</body>
</html>
I hope that helps a little bit
Carlos Federico Puebla Larregle
21,074 PointsIf you go check out the flask doc page: http://flask.pocoo.org/docs/0.10/tutorial/templates/#tutorial-templates you will see there that they use the format:
{% block body %}{% endblock %}
Without typing which block is ending, I think that's why they are checking it out like that.
Ken Tuntiansin
1,523 PointsKen Tuntiansin
1,523 PointsThat works but it is very strange because it works fine on my computer just so. I'm guessing the test checks for {% endblock %} only.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> {% block title %} THIS IS TITLE {% endblock title %} </title> </head> <body> {% block content %} {% endblock content %} <p>STUFF STUFF STUFF</p> </body> </html>
syed bukhari
4,028 Pointssyed bukhari
4,028 PointsWhy is that when entering the title, you do not use ' in beginning of title, and if you do Workspace does not accept the code?