flask 自定义404,500页面

from flask import Flask
from flask import abort
from flask import render_template

app = Flask(name)

@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'),404
@app.errorhandler(500)
def page_not_found(e):
return render_template('500.html'),500

@app.route('/')
def index():
abort(404)

if name == 'main':
app.run()

你可能感兴趣的:(flask 自定义404,500页面)