diff options
author | Michael Palimaka <kensington@gentoo.org> | 2017-07-26 21:10:12 +1000 |
---|---|---|
committer | Michael Palimaka <kensington@gentoo.org> | 2017-07-26 21:15:43 +1000 |
commit | 5507e58fc4c5acf0642fd59cb226d01a4d70b610 (patch) | |
tree | 9377a2f92dae2e3f1237b32e186302411ef19b1c | |
parent | gitignore: ignore grumpy database (diff) | |
download | grumpy-5507e58fc4c5acf0642fd59cb226d01a4d70b610.tar.gz grumpy-5507e58fc4c5acf0642fd59cb226d01a4d70b610.tar.bz2 grumpy-5507e58fc4c5acf0642fd59cb226d01a4d70b610.zip |
Add 404 error handling.
-rw-r--r-- | backend/__init__.py | 6 | ||||
-rw-r--r-- | frontend/templates/404.html | 16 |
2 files changed, 21 insertions, 1 deletions
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 <what_is_passed_here>/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 %} + +<div class="jumbotron"> + <i class="fa fa-question-circle" style="color:#ccc;float:right;font-size:100pt;" id="box-icon"></i> + <h1 id="box-title">Not Found <small>(404)</small></h1> + + <p><strong>We couldn't find the resource you were trying to request.</strong></p> + + <p>If you've followed a link <strong>on our websites</strong> that led here, please <a href="https://www.gentoo.org/inside-gentoo/contact/">let us know</a> about the broken link. + <hr> + <p><small>Maybe something is wrong after all, and there's more information available on our <em>Infrastructure Status</em> website:</small></p> + <p><a class="btn btn-primary" role="button" href="https://infra-status.gentoo.org/#pk_campaign=err&pk_kwd=404">Visit Infra Status</a></p> +</div> + +{% endblock %} |