diff options
Diffstat (limited to 'src/website.py')
| -rw-r--r-- | src/website.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/website.py b/src/website.py new file mode 100644 index 0000000..2da85c5 --- /dev/null +++ b/src/website.py @@ -0,0 +1,53 @@ +import datetime + +import quart as q + +SPECIAL_PATHS = ("/", "/admin/") + +blueprint = q.Blueprint("website", __name__) + + +def label_active(path: str): + return ( + q.request.path.startswith(path) + if path not in SPECIAL_PATHS + else q.request.path == path + ) + + +def format_timestamp(dt: datetime.datetime): + return dt.astimezone(datetime.timezone.utc).strftime("%a %d %b %Y at %H:%M") + + +blueprint.add_app_template_global(label_active, "label_active") +blueprint.add_app_template_global(format_timestamp, "format_ts") + + +@blueprint.route("/") +async def index(): + return await q.render_template( + "index.html", title="Home", description="home's the best place, right?" + ) + + +@blueprint.route("/home") +async def redirect_to_index(): + return q.redirect("/") + + +@blueprint.route("/projects") +async def projects(): + return await q.render_template( + "projects.html", + title="Projects", + description="things I have built throughout my career", + ) + + +@blueprint.route("/clocks") +async def clocks(): + return await q.render_template( + "clocks.html", + title="Clocks", + description="various clocks from events in my life", + ) |
