Someone
Someone

Reputation: 105

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?

Upvotes: 0

Views: 278

Answers (1)

Suever
Suever

Reputation: 65430

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

Upvotes: 1

Related Questions