Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ venv.bak/
# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
Expand Down
13 changes: 11 additions & 2 deletions site/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys

import yaml
from flask import Flask, render_template, send_from_directory, url_for
from flask import Flask, abort, render_template, send_from_directory, url_for
from flask_frozen import Freezer # Added

from config import ORGANIZATIONS_DIR_PATH, ORGANIZATIONS_SLUG_FIELD_NAME
Expand Down Expand Up @@ -46,7 +46,9 @@ def get_static_files_list():


for filename in get_static_files_list():
app.route(f"/{filename}", strict_slashes=False, endpoint=filename)(lambda f=filename: static_file(f))
app.route(f"/{filename}", strict_slashes=False, endpoint=filename)(
lambda f=filename: static_file(f)
)


@freezer.register_generator
Expand All @@ -57,6 +59,11 @@ def generate_favicon_statics():
yield url_for(static)


@app.errorhandler(404)
def page_not_found(e):
return render_template("404.html"), 404


# Generated css
@app.route("/output.css")
def outputCss():
Expand All @@ -74,6 +81,8 @@ def index():
@app.route("/<string:org_name>/", strict_slashes=False)
def organization_page(org_name):
filename = organizations.get(org_name)
if not filename:
abort(404)
with open(f"{ORGANIZATIONS_DIR_PATH}/{filename}") as org:
data = yaml.safe_load(org)
return render_template("organization.html", data=data)
Expand Down
7 changes: 7 additions & 0 deletions site/templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "base.html" %} {% block content %}

<div class="mt-10 flex justify-center">
<h1 class="text-black text-xl text-center">Oops, page not found</h1>
</div>

{% endblock content %}