flask中温柔显示404等错误


写下下面两个视图函数,然后在模板中写下错误时展现的内容,当然模板名,函数名是可以改的哟
@app.errorhandler(404)
def page_not_found(error):
return render_template('404.html'),404

@app.errorhandler(500)
def internal_error(error):
return render_template('500.html'),500


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM