Python Flask Basics Templates and Static Files Template Inheritance

Jothum Chitewe
Jothum Chitewe
4,630 Points

index.html

put the contents of the <title>

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"%}

{% block title %} Homepage {% endblock %}
{% block content %}
<h1>{% block content %} Smells Like Bakin'!</h1>
{% endblock %}
<p>Welcome to my bakery web site!</p>
<
templates/layout.html
<html>
  <head>
    <title>{% block title %}Smells Like Bakin'{% endblock %}</title>
  </head>
  <body>
  {% block content %}{% endblock %}
  </body>
</html>