base:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>知了课堂</title>
</head>
<body>
<p>我是父母版中的</p>
{% block  body_block %}

{% endblock %}
</body>
</html>

index:

{% extends 'base.html' %}
{% block body_block %}
我是 body_block中的代码
{% endblock %}

.py

from flask import Flask,render_template

app = Flask(__name__)
app.config.update(TEMPLATE_AUTO_RELOAD=True)



@app.route('/')
def index():
    return render_template("index.html")

@app.route('/detail/')
def my_list():
    return render_template("course_detail.html")

if __name__ == '__main__':
    app.run(debug=True)

flask-模版继承详解

flask-模版继承详解

flask-模版继承详解

flask-模版继承详解

flask-模版继承详解

相关文章:

  • 2021-06-17
  • 2021-09-24
  • 2021-09-06
  • 2023-03-18
  • 2022-12-23
  • 2021-07-28
  • 2021-12-05
猜你喜欢
  • 2021-12-21
  • 2021-09-05
  • 2021-11-28
  • 2021-08-20
  • 2021-07-10
  • 2022-02-15
  • 2022-12-23
相关资源
相似解决方案