自定义错误页面
views.py
@app.errorhandler(404) def internal_error(error): return render_template(‘error.html‘,errorcode = 404, errormsg = ‘page not found‘) @app.errorhandler(500) def internal_error(error): return render_template(‘error.html‘,errorcode = 500, error = ‘server not found‘)
error.html
{% extends ‘base.html‘ %} {% block content %} <div class=‘content-intermediate‘> <h4>Error: {{errorcode}}</h4> <p class="content-font">{{errormsg}}</p> <p class="content-font"><a href="{{url_for(‘index‘)}}">Back</a></p> </div> {% endblock %}
效果:
时间: 2024-11-12 07:15:42