Python Flask Basics Templates and Static Files Template Inheritance

Where's the error in my code ? =s

{% extends 'layout.html' %} {{ super() }} Homepage{% endblock %} {% block content %} <h1>Smells Like Bakin'!</h1> <p>Welcome to my bakery web site!</p> {% endblock %}

flask_app.py
from flask import Flask
from flask import render_template

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')
templates/index.html
{% extends 'layout.html' %}
{{ super() }} Homepage{% endblock %}
  {% block content %}
<h1>Smells Like Bakin'!</h1>
<p>Welcome to my bakery web site!</p>
  {% endblock %}
templates/layout.html
<!doctype html>
<html>
  <head><title>{% block title %}Smells Like Bakin'{% endblock %}</title></head>
<body>
  {% block content %}{% endblock %}
</body>
</html>

1 Answer

Josh Keenan
Josh Keenan
17,358 Points

Index.html: start the title block, you end it without opening it

{% block title %} {{ super() }} Homepage{% endblock %}