From 7a33856a527aebbd8d2a624c6d5937c25c9a1d90 Mon Sep 17 00:00:00 2001 From: Emma Terzioglu Date: Fri, 13 Mar 2026 13:49:15 -0700 Subject: initial commit new website repo yay!!! --- src/__init__.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/__init__.py (limited to 'src/__init__.py') diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..f6ad74a --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,42 @@ +import asyncpg +import quart as q +from dotenv import dotenv_values + +from . import admin, blog, website + +app = q.Quart(__name__) +app.config.from_mapping(dotenv_values()) +app.debug = app.config["STAGE"] == "debug" +app.permanent_session_lifetime = admin.MAX_LOGIN_TIME + +app.register_blueprint(blog.blueprint) +app.register_blueprint(website.blueprint) +app.register_blueprint(admin.blueprint) + + +@app.while_serving +async def db_lifespan(): + app.pool = await asyncpg.create_pool(app.config["DATABASE"]) + yield + await app.pool.close() + + +@app.before_request +async def make_login_permanent(): + q.session.permanent = True + + +@app.errorhandler(404) +async def not_found(error): + return ( + await q.render_template( + "404.html", + title="Not Found!", + description="the page you were looking for couldn't be found. sorry...", + ), + 404, + ) + + +def run() -> None: + app.run() -- cgit v1.2.3