模版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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM