mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add aurweb.db.session
+ Added Session class and global session object to aurweb.db, these are sessions created by sqlalchemy ORM's sessionmaker and will allow us to use declarative/imperative models. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
7c65604dad
commit
4238a9fc68
6 changed files with 260 additions and 32 deletions
|
@ -7,30 +7,36 @@ from starlette.middleware.sessions import SessionMiddleware
|
|||
|
||||
import aurweb.config
|
||||
|
||||
from aurweb.db import get_engine
|
||||
from aurweb.routers import html, sso
|
||||
|
||||
routes = set()
|
||||
|
||||
# Setup the FastAPI app.
|
||||
app = FastAPI()
|
||||
app.mount("/static/css",
|
||||
StaticFiles(directory="web/html/css"),
|
||||
name="static_css")
|
||||
app.mount("/static/js",
|
||||
StaticFiles(directory="web/html/js"),
|
||||
name="static_js")
|
||||
app.mount("/static/images",
|
||||
StaticFiles(directory="web/html/images"),
|
||||
name="static_images")
|
||||
|
||||
session_secret = aurweb.config.get("fastapi", "session_secret")
|
||||
if not session_secret:
|
||||
raise Exception("[fastapi] session_secret must not be empty")
|
||||
|
||||
app.add_middleware(SessionMiddleware, secret_key=session_secret)
|
||||
@app.on_event("startup")
|
||||
async def app_startup():
|
||||
session_secret = aurweb.config.get("fastapi", "session_secret")
|
||||
if not session_secret:
|
||||
raise Exception("[fastapi] session_secret must not be empty")
|
||||
|
||||
app.include_router(sso.router)
|
||||
app.include_router(html.router)
|
||||
app.mount("/static/css",
|
||||
StaticFiles(directory="web/html/css"),
|
||||
name="static_css")
|
||||
app.mount("/static/js",
|
||||
StaticFiles(directory="web/html/js"),
|
||||
name="static_js")
|
||||
app.mount("/static/images",
|
||||
StaticFiles(directory="web/html/images"),
|
||||
name="static_images")
|
||||
|
||||
app.add_middleware(SessionMiddleware, secret_key=session_secret)
|
||||
app.include_router(sso.router)
|
||||
app.include_router(html.router)
|
||||
|
||||
get_engine()
|
||||
|
||||
# NOTE: Always keep this dictionary updated with all routes
|
||||
# that the application contains. We use this to check for
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue