蓝图导入:
将所有的视图函数都以蓝图写在info目录里.info是对业务逻辑的处理,新建module目录,将所有的蓝图写在这个目录里,在module新建python package index(主要功能名) 如图:
 代码如下: init:
from flask import Blueprint
index_blue=Blueprint("index",__name__)
from . import views
views:
from . import index_blue
from flask import render_template,current_app
@index_blue.route("/")
def hello():
return render_template("news/index.html")
在app中注册蓝图:
我们app是在info的init文件create_app创建的,所以我们在info的init文件导入蓝图
以下面这种方式导入蓝图是有问题的 
蓝图导入的问题
 我们知道导入一个包其实就是在执行文件里的所有代码,我们从报错的文件从上往下点就会发现相关问题如图: 
解决办法
我们修改info的init文件中的蓝图导包,如图: 
|