08.蓝图
[toc]{type: “ol”, level: [2, 3, 4, 5]}
蓝图使用
#第一步在app中注册蓝图,括号里是一个蓝图对象
app.register_blueprint(user.us)
# 第二步,在不同文件中注册路由时,直接使用蓝图对象注册
# 不用使用app对象,避免了循环导入的问题
from flask import Blueprint
us = Blueprint('user', __name__)
@us.route('/login.html', methods=['GET', "POST"])
中小型项目
项目名字
-pro_flask文件夹
-__init__.py
-templates
-login.html
-statics
-code.png
-views
-blog.py
-account.py
-user.py
-run.py
大型项目
项目名
-pro_flask文件夹
-__init__.py
-web
-__init__.py
-static
-views.py
-templates
-admin
-templates
-static
-views.py
-__init__.py
-run.py