flask 蓝图下 多个视图文件放入一个蓝图的写法

目录:

blueprint.py

book.py

扫描二维码关注公众号,回复: 10490168 查看本文章

 user.py

app目录下的__init__.py

fisher.py

第二种写法:

把Blueprint.py中代码,写到web目录 __init__.py文件中,然后 导入book 和 user 的py文件

from flask import Blueprint
web=Blueprint("web",__name__)

from app.web import book
from app.web import user

在把 app目录下的__init__.py register_blueprint函数 导入 web下 __init__.py中的web蓝图排插

def register_blueprint(app):
  from app.web import web
  app.register_blueprint(web)

猜你喜欢

转载自www.cnblogs.com/kaibindirver/p/12635687.html