2017-09-14 93 views
0

我为烧瓶应用程序编写了自己的验证模块。它还没有准备好,当我在其他模块上工作时可能会很痛苦。我注释掉的代码行,我注册的蓝图:烧瓶 - 检查蓝图是否存在

# app.register_blueprint(auth_module) 

但如何我检查,看看是否在另一个控制器存在此模块:

/mod_home/controllers.py

@mod_home.route('', methods=['GET']) 
def index(): 
    # if mod_auth: <-- THIS LINE??? 
     # check if user is logged in, redirect if needed 
    # else: 
    return render_template('index.html') 
+0

好了,我找到了答案......不知道我是否应该关闭的问题或答案呢? – Jeff

+0

你最好发布答案,这完全没问题 –

回答

0
from src import app 
... 
auth_mod_used = 'auth' in app.blueprints.keys() 

这里假定dir结构为:

/project 
    /src 
    * __init.py__ 

而且__init.py__文件包含:

app = Flask(__name__)