From 5507e58fc4c5acf0642fd59cb226d01a4d70b610 Mon Sep 17 00:00:00 2001 From: Michael Palimaka Date: Wed, 26 Jul 2017 21:10:12 +1000 Subject: Add 404 error handling. --- backend/__init__.py | 6 +++++- frontend/templates/404.html | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 frontend/templates/404.html diff --git a/backend/__init__.py b/backend/__init__.py index f8bfd6a..f9b859a 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -1,4 +1,4 @@ -from flask import Flask +from flask import render_template, Flask from flask_sqlalchemy import SQLAlchemy app = Flask("frontend") # FIXME: Finish rearranging frontend/backend modules properly instead of pretending to be frontend in backend/__init__ because jinja templates are looked for from /templates @@ -13,3 +13,7 @@ GrumpyView.register(app) SetupView.register(app) __all__ = ["app", "db"] + +@app.errorhandler(404) +def not_found(error): + return render_template('404.html'), 404 diff --git a/frontend/templates/404.html b/frontend/templates/404.html new file mode 100644 index 0000000..c945739 --- /dev/null +++ b/frontend/templates/404.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} +{% block content %} + +
+ +

Not Found (404)

+ +

We couldn't find the resource you were trying to request.

+ +

If you've followed a link on our websites that led here, please let us know about the broken link. +


+

Maybe something is wrong after all, and there's more information available on our Infrastructure Status website:

+

Visit Infra Status

+
+ +{% endblock %} -- cgit v1.2.3-65-gdbad