按照官方文档,在蓝图文件夹新建一个 errors.python 文件。写上
@main.app_errorhandler(404)
def page_not_found(e):
return render_template('404.html'),404
在蓝图的 init.python 写上 from . import errors
现在有几点疑问,1、按照我的想法,当写上 app_errorhandler,应该是用来自定义全局错误页面的,errorhandler 是用来自定义蓝图内部的错误页面的。2、运行过后,生成的 404 错误还是显示默认的 404 错误页面。app_errorhandler 和 errorhandler 都不生效。
@main.app_errorhandler(404)
def page_not_found(e):
return render_template('404.html'),404
在蓝图的 init.python 写上 from . import errors
现在有几点疑问,1、按照我的想法,当写上 app_errorhandler,应该是用来自定义全局错误页面的,errorhandler 是用来自定义蓝图内部的错误页面的。2、运行过后,生成的 404 错误还是显示默认的 404 错误页面。app_errorhandler 和 errorhandler 都不生效。