模版include的用法

from flask import Flask,render_template


app = Flask(__name__)


@app.route('/')
def hello_world():
    return render_template('include.html')


if __name__ == '__main__':
    app.run(debug=True)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>知了课堂</title>
#主模板
</head>
<body>
    {% include 'common/header.html' %}
    <div class="context">
        中间的
    </div>
    {% include 'common/footer.html' %}
</body>
</html>

#header公用的部分封装起来
<style> .nav ul { overflow: hidden; } .nav ul li{ float: left; margin: 0 20px; list-style-type: none; } </style> <nav class="nav"> <ul> <li>首页</li> <li>课程详情</li> <li>视频教程</li> <li>关于我们</li> </ul> </nav>
#footer公用的部分封装
<div class="footer"> 末尾的 </div>

原文地址:https://www.cnblogs.com/wuheng-123/p/9679740.html