首页 > 其他 > 详细

模版继承

时间:2018-02-18 16:18:56      阅读:211      评论:0      收藏:0      [点我收藏+]
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 %}

 

模版继承

原文:https://www.cnblogs.com/themost/p/8452859.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!