我对 Flask 比较陌生,但我已经发现需要使用蓝图。但是,在我的蓝图中,我试图渲染一个模板,但出现错误。
当连接为 WSGI 应用程序(在 Dreamhost 上)时,render_template 函数返回此错误:
File ".../app/ui/__init__.py", line 95, in index
response = make_response(render_template('index.html', **data))
File ".../flask/templating.py", line 123, in render_template
ctx.app.update_template_context(context)
AttributeError: 'NoneType' object has no attribute 'app'
但是,当我在调试模式下直接调用 app.py 时,它可以完美运行!(以下)
python app/app.py
在 app.py 中:
if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')
编辑:渲染模板:
@ui_blueprint.route('/', methods=['GET'])
@ui_blueprint.route('/home', methods=['GET'])
def index():
    data = {
        'title': 'Index'
    }
    response = make_response(render_template('index.html', **data))
    return response
编辑2: ctx是:
None在 WSGI 应用案例中<RequestContext 'http://aaa.bbb.com:5000/' [GET] of __init__>在直接调用的情况下
有什么想法可以解决这个错误吗?谢谢!