我在Flask Blueprints正常运行时遇到困难

我正在将虚拟网页项目从标准的app.route配置转换为使用flask.Blueprint现在正在生成404错误,导致无法修复的问题。

这是我的应用代码:


app = flask.flask(__name__)


def main():
    register_blueprints()
    app.run(debug=True)


def register_blueprints():
    from inspection_com.views import home_views
    from inspection_com.views import donation_views
    from inspection_com.views import employee_views

    app.register_blueprint(home_views.blueprint)
    app.register_blueprint(donation_views.blueprint)
    app.register_blueprint(employee_views.blueprint)


if __name__ == '__main__':
    main()

这是我的一个名为home_views的视图:


from inspection_com.infrastructure.view_modifiers import response

blueprint = flask.Blueprint('home',__name__,template_folder='templates')


@blueprint.route('/')
@response(template_file='home/index.html')
def index():
    return {}


@blueprint.route('/about')
@response(template_file='home/about.html')
def about():
    return {}

从我从主app.py文件中简单调用app.route('/')以来,路由和响应代码都没有改变。

任何帮助将不胜感激。当我不认为自己在做任何明显错误的事情时,我会尝试解决此问题。

-凯文

hank112 回答:我在Flask Blueprints正常运行时遇到困难

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3169768.html

大家都在问