from flask import Flask, render_template app = Flask(__name__) @app.route("/one") def get_one(): return render_template("one.html") @app.route("/two") def get_two(): return render_template("two.html") if __name__ == '__main__': app.run(debug=True) #base.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div>Header</div> <div> {% block content %} {% endblock %} </div> <div>Footer</div> </body> </html> #one.html {% extends "base.html" %} {% block content %} <h2>这恐怕是第一页</h2> {% endblock %} #two.html {% extends "base.html" %} {% block content %} <h2>这应该是第二页</h2> {% endblock %}