Add custom error pages

This commit is contained in:
coolneng 2020-06-12 22:50:08 +02:00
parent bec6b19d1c
commit 4f5013460f
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
4 changed files with 35 additions and 0 deletions

12
app/errors.py Normal file
View File

@ -0,0 +1,12 @@
from flask import render_template
from app import app
@app.errorhandler(404)
def not_found_error(error):
return render_template("404.html"), 404
@app.errorhandler(500)
def internal_error(error):
return render_template("500.html"), 500

6
app/templates/404.html Normal file
View File

@ -0,0 +1,6 @@
{% extends "base.html" %}
{% block app_content %}
<h1>Sorry, we couldn't find that</h1>
<p><a href="{{ url_for('index') }}">Back</a></p>
{% endblock %}

8
app/templates/500.html Normal file
View File

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% block app_content %}
<h1>An unexpected error has occurred</h1>
<p>The administrator has been notified!</p>
<p>If he gets too many notifications, we might replace him with an AI</p>
<p><a href="{{ url_for('index') }}">Back</a></p>
{% endblock %}

View File

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% import 'bootstrap/wtf.html' as wtf %}
{% block app_content %}
<h1>Dataset visualization</h1>
<img src="data:image/png;base64,{{ plot }}" alt="Image Placeholder">
<img src="data:image/png;base64,{{ map }}" alt="Image Placeholder">
<p><a href="{{ url_for('data') }}">Back</a></p>
{% endblock %}