I am using Python Flask on IIS and part of my __init__.py
file looks like the below
def handle_error_404(error):
"""
404
"""
app.logger.error(error)
flash(f'Server says: {error}', 'error')
return render_template('404.jinja2', layout = 'container')
def handle_error_400(error):
"""
400
"""
app.logger.error(error)
flash(f'Server says: {error}', 'error')
return render_template('400.jinja2', layout = 'container')
def handle_error_500(error):
"""
500
"""
app.logger.error(error)
flash(f'Server says: {error}', 'error')
return render_template('500.jinja2', layout = 'container')
app.errorhandler(400)(handle_error_400)
app.errorhandler(404)(handle_error_404)
app.errorhandler(500)(handle_error_500)
If I go to a page that does not exist thus triggering a 404, the 404 template comes up. However if I cause an error, I get the default IIS 500 error page as below instead of my template
Any suggestions on how to prevent IIS serving up its own 500 error page and instead serve up mine? I understand I can amend settings below but how would I then pass data to my template? as I'm doing in render_template
I try adding the following to web.config:
<httpErrors existingResponse="Passthrough" />
I now instead get:
At this point I feel like it's going to be easiest to not bother using IIS