Add error handling, fixed a bug, etc.

This commit is contained in:
Elliott Pardee 2020-01-04 15:09:25 -05:00
parent 35f60a955a
commit aa9196b755
7 changed files with 44 additions and 7 deletions

View File

@ -18,6 +18,7 @@
import os import os
import flask import flask
import werkzeug
from canon_law import central from canon_law import central
@ -34,4 +35,6 @@ def create_app():
app.register_blueprint(api.bp) app.register_blueprint(api.bp)
app.register_blueprint(frontend.bp) app.register_blueprint(frontend.bp)
app.register_error_handler(werkzeug.exceptions.HTTPException, frontend.error_page)
return app return app

View File

@ -17,6 +17,7 @@
""" """
import flask import flask
import werkzeug
import tinydb import tinydb
import random import random
@ -40,7 +41,7 @@ page_titles = {
def index(): def index():
return flask.render_template("index.html") return flask.render_template("index.html")
@bp.route("/c/")
@bp.route("/c/<council>/") @bp.route("/c/<council>/")
def read_council(council=None): def read_council(council=None):
if council in page_titles.keys(): if council in page_titles.keys():
@ -75,3 +76,8 @@ def about():
@bp.route("/disclaimer/") @bp.route("/disclaimer/")
def disclaimer(): def disclaimer():
return flask.render_template("disclaimer.html") return flask.render_template("disclaimer.html")
@bp.errorhandler(werkzeug.exceptions.HTTPException)
def error_page(error):
return flask.render_template("error.html", error=error), error.code

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -70,7 +70,7 @@ button:focus {
color: white !important; color: white !important;
} }
input { padding: 10px; } input { padding: 10px; border-radius: -1px; }
header .dropdown-content { header .dropdown-content {
display: none; display: none;
@ -128,8 +128,7 @@ footer {
} }
table { table {
display: block; display: table-cell;
margin: 0 auto;
} }
table, th, td { table, th, td {

View File

@ -12,8 +12,21 @@
<br><br> <br><br>
<h3>Personnel</h3> <h3>Personnel</h3>
<h6 style="margin-top: -10px;">(Title: Name, Jurisdiction - Email)</h6>
Project Lead: Seraphim Pardee, OCA - <a href="mailto:vypr@oikonomia.xyz">vypr@oikonomia.xyz</a> <table>
<tr>
<th>role</th>
<th>name</th>
<th>jurisdiction</th>
<th>email</th>
</tr>
<tr>
<td>project lead</td>
<td><a href="https://vypr.xyz">Seraphim</a></td>
<td>OCA / Bulgarian Diocese</td>
<td><a href="mailto:vypr@oikonomia.xyz">click</a></td>
</tr>
</table>
<br><br> <br><br>

View File

@ -0,0 +1,16 @@
{% extends "base.html" %}
{% block title %}error {{ error.code }}{% endblock %}
{% block main %}
<h1>{{ error.code }}</h1>
<h3 style="text-align: center;">
{% if error.code == 404 %}
<img src="{{ url_for('static', filename='phanurius.jpg') }}">
<br>
You can pray to St. Phanourios to help you find what you are looking for.
{% else %}
{{ error.description }}
{% endif %}
</h3>
{% endblock %}

View File

@ -10,6 +10,6 @@
<br><br> <br><br>
Wanna try a <a href="{{ url_for('frontend.council', council=random_council) }}">random council</a>? Wanna try a <a href="{{ url_for('frontend.read_council', council=random_council) }}">random council</a>?
</h3> </h3>
{% endblock %} {% endblock %}