【问题标题】:how to bind a error_handle in flask blueprint如何在烧瓶蓝图中绑定error_handle
【发布时间】:2018-10-27 04:51:27
【问题描述】:

嗯嗯嗯。问题是,我有三个蓝图,并在蓝图上使用 subdomian,例如'www','admin','mobile',并使用 url_prefix 注册到应用程序默认为“/”

app.register_blueprint(admin_blueprint)
app.register_blueprint(mobile_blueprint)
app.register_blueprint(front_blueprint)

当 font_blueprint 绑定 app_errorhandler(404).

烧瓶文件:

app_errorhandler(代码):

与 Flask.errorhandler() 类似,但用于蓝图。此处理程序用于所有请求,即使在蓝图之外

在蓝图之外。,那么如何将 error_page 与单个蓝图绑定

感谢帮助我

【问题讨论】:

    标签: flask


    【解决方案1】:

    你可以register a error handler to a blueprint

    admin_blueprint = Blueprint("admin", __name__)
    
    admin_blueprint.error_handler(404)
    def page_not_found(e):
        pass
    

    【讨论】:

      猜你喜欢
      • 2012-06-16
      • 1970-01-01
      • 2012-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-25
      • 2015-07-16
      • 1970-01-01
      相关资源
      最近更新 更多