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

 

相关文章:

  • 2022-02-12
  • 2021-10-15
  • 2022-03-09
  • 2021-07-13
猜你喜欢
  • 2021-09-06
  • 2021-07-28
  • 2021-10-10
  • 2021-09-05
  • 2021-04-08
  • 2021-06-30
  • 2022-12-23
相关资源
相似解决方案