From 31d2808a43f25052b4ee8ff7404f627439a28026 Mon Sep 17 00:00:00 2001 From: Roberto Hueso Gómez Date: Fri, 4 Sep 2020 13:20:11 +0200 Subject: Add 404 default error handler. This handles HTTP 404 page does not exist errors. --- ogcp/templates/error.html | 9 +++++++++ ogcp/views.py | 4 ++++ 2 files changed, 13 insertions(+) create mode 100644 ogcp/templates/error.html (limited to 'ogcp') diff --git a/ogcp/templates/error.html b/ogcp/templates/error.html new file mode 100644 index 0000000..878a5de --- /dev/null +++ b/ogcp/templates/error.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} + +{% block content %} + +

+ {{ _('Error!') }}: {{ message }} +

+ +{% endblock %} diff --git a/ogcp/views.py b/ogcp/views.py index 0772e33..1621455 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -15,6 +15,10 @@ def load_config(): g.server = OGServer() g.server.load_config('ogcp/cfg/ogserver.json') +@app.errorhandler(404) +def page_not_found(error): + return render_template('error.html', message=error), 404 + @app.route('/') def index(): return render_template('base.html') -- cgit v1.2.3-18-g5258