From 656932feb137043979e963a953615d9583fda2b5 Mon Sep 17 00:00:00 2001 From: gpkvt Date: Sun, 4 Jun 2023 14:35:24 +0200 Subject: [PATCH] 500 error page added --- game.py | 10 ++++++++++ templates/404.html | 2 +- templates/500.html | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 templates/500.html diff --git a/game.py b/game.py index b6d329a..685d758 100755 --- a/game.py +++ b/game.py @@ -69,6 +69,15 @@ def page_not_found(e): desc = config.get('i18n', 'desc') return render_template('404.html', title=title, lang=lang, desc=desc, theme=theme, url=url), 404 +@app.errorhandler(500) +def internal_server_error(e): + lang = config.get('i18n', 'lang') + title = config.get('i18n', 'title') + url = config.get('main', 'base_url') + theme = config.get('main', 'theme') + desc = config.get('i18n', 'desc') + return render_template('500.html', title=title, lang=lang, desc=desc, theme=theme, url=url), 500 + @app.route("/") def hello(): lang = config.get('i18n', 'lang') @@ -113,6 +122,7 @@ def getContent(): return result app.register_error_handler(404, page_not_found) +app.register_error_handler(500, internal_server_error) if __name__ == "__main__": from waitress import serve diff --git a/templates/404.html b/templates/404.html index b9984ac..63f694d 100644 --- a/templates/404.html +++ b/templates/404.html @@ -3,7 +3,7 @@ {% block main %}
-

404 - Page not found.

+

404 - Page not found

Sorry, the page you requested does not exists.

[Home]

diff --git a/templates/500.html b/templates/500.html new file mode 100644 index 0000000..c7e544b --- /dev/null +++ b/templates/500.html @@ -0,0 +1,16 @@ +{% extends 'base.html' %} + +{% block main %} +
+
+

500 - Internal Server Error

+

Sorry, the page you requested caused an internal server error.

+

[Home]

+
+
+ +{% endblock %}