templates/layout.html
<!doctype html> <html> <head> <title>{{ title }}</title> </head> <body> {% block content %} {% endblock %} </body> </html>
templates/hello.html
{% extends "layout.html" %} {% block content %} <h3></h3> こんにちは。{{ name }}さん。 {% endblock %}
hello.py
from flask import Flask, render_template app = Flask(__name__) @app.route('/') def hello(): name = "Hoge" return render_template('hello.html', title='flask test', name=name) if __name__ == "__main__": app.run(debug=True, host='192.168.56.10', port=8000)