diff --git a/app/errors/handlers.py b/app/errors/handlers.py index afbc543a..a5e49f90 100644 --- a/app/errors/handlers.py +++ b/app/errors/handlers.py @@ -40,3 +40,13 @@ def internal_server_error(e): response.status_code = 500 return response return render_template('errors/500.html.j2', title='Internal Server Error'), 500 + + +@bp.app_errorhandler(503) +def service_unavailable_error(e): + if (request.accept_mimetypes.accept_json + and not request.accept_mimetypes.accept_html): + response = jsonify({'error': 'service unavailable'}) + response.status_code = 503 + return response + return render_template('errors/503.html.j2', title='Service Unavailable'), 503 diff --git a/app/templates/errors/503.html.j2 b/app/templates/errors/503.html.j2 new file mode 100644 index 00000000..eb10cfb0 --- /dev/null +++ b/app/templates/errors/503.html.j2 @@ -0,0 +1,19 @@ +{% extends "base.html.j2" %} + +{% block page_content %} +
+

{{ title }}

+

{{ request.path }}

+

Alternatively, you can visit the Main Page or read more information about this type of error.

+
+ + +{% endblock page_content %}