from flask import Flaskfrom flask import render_templateapp = Flask(__name__)@app.route('/')def switch(): return render_template('switch.html')@app.route('/login/')def login(): return render_template('login.html')@app.route('/register/')def register(): return render_template('register.html')if __name__ == '__main__': app.run(debug=True)
父模板
首页 {% block logintitle %}{% endblock %} {% block registertitle %}{% endblock %} {% block loginhead %}{% endblock %}{% block registerhead %}{% endblock %}> {% block loginbody %}{% endblock %}{% block registerbody %}{% endblock %}
登录页面
{% extends 'switch.html' %}{% block logintitle %}欢迎来到登录界面,请登录{% endblock %}{% block loginhead %}{% endblock %}{% block loginbody %}中国标准时间
{% endblock %}>登陆界面
注册页面
{% extends 'switch.html' %}{% block registertitletitle %}欢迎来到注册界面,请登录{% endblock %}{% block registerhead %}{% endblock %}{% block registerbody %}中国标准时间
{% endblock %}>注册界面