Иван Сушков Иван Сушков - 15 days ago 10
Python Question

How to change error page in Flask?

I have a method, that allowed only post

requests
. When i send send
get
request, i get a standard error page.

Can i change it or make redirect for another page?

Answer

You can use the errorhandler decorator to provide custom handling of a 405 error.

from flask import render_template

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