diff options
| author | Emma Terzioglu <emreterzioglu49@gmail.com> | 2026-03-13 13:49:15 -0700 |
|---|---|---|
| committer | Emma Terzioglu <emreterzioglu49@gmail.com> | 2026-03-13 13:49:15 -0700 |
| commit | 7a33856a527aebbd8d2a624c6d5937c25c9a1d90 (patch) | |
| tree | 855c642394e7ba1de40b8bb8737be12bec0aedaf /src/__init__.py | |
initial commit
new website repo yay!!!
Diffstat (limited to 'src/__init__.py')
| -rw-r--r-- | src/__init__.py | 42 |
1 files changed, 42 insertions, 0 deletions
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() |
