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>

模版include的用法

#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>

模版include的用法

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
  • 2021-09-04
  • 2021-12-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
相关资源
相似解决方案