-1

I am using Flask and blueprints on IIS. My issue is that when the 500 error is triggered it loads the default IIS 500 template and not what I want.

I've tried several things and this is where I am. I have the following code

from flask import render_template,Blueprint
errorbp = Blueprint("errorbp",__name__)

@errorbp.app_errorhandler(404)
def page_not_found(e):
    return "404", 404

@errorbp.app_errorhandler(500)
def internal_server_error(e):
    return "500", 500

If I visit a page that does not exist, I get "404" back as intended. If I create an error on purpose, I get the following

enter image description here

Any suggestions as to what to do? I presume I may need to do something with IIS at this point but what? I've edited/remove the 5xx status codes/page and still nothing

pee2pee
  • 3,619
  • 7
  • 52
  • 133

1 Answers1

-1

What you need to do is, open the error pages module, double-click the 500 status code, set the path of your template in the file path, and IIS will send the content of the file as a custom error response.

In addition, IIS has two other ways to respond to an error: by executing an URL or by redirecting the request.

enter image description here

JennyDai
  • 214
  • 1
  • 5
  • How do I pass data to the template? So is the Flask errorhandler for 500 redundant for IIS and if so why is it featured on every guide and tutorial I've come across? Also how come the 404 works fine? – pee2pee Aug 04 '22 at 07:13