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", )