今天想在自定义下错误页面,发现网上的都是做了个简单的例子,跟官网一样,但是在实际项目中一般都是用蓝图的,注意是在蓝图下自定义错误页面。
在蓝图下使用:@蓝图名称.app_errorhandler(404)
先在templates目录下新建404页面
@main_bp.app_errorhandler(404)
def page(e):
'''页面未找到错误'''
print('404**************************************', e)
return render_template('404.html'), 404