css moar correction

This commit is contained in:
2025-11-18 00:53:12 +01:00
parent e74553a482
commit 4b96b17368
3 changed files with 11 additions and 8 deletions

View File

@@ -29,6 +29,7 @@ class ListenerManager:
channel_name=user.username, channel_name=user.username,
client_id=settings.TWITCH_CLIENT_ID, client_id=settings.TWITCH_CLIENT_ID,
client_secret=settings.TWITCH_CLIENT_SECRET, client_secret=settings.TWITCH_CLIENT_SECRET,
bot_id=user.platform_user_id,
websocket_manager=websocket_manager, websocket_manager=websocket_manager,
db_user_id=user.id db_user_id=user.id
) )

17
main.py
View File

@@ -59,9 +59,6 @@ async def lifespan(app: FastAPI):
app = FastAPI(lifespan=lifespan) app = FastAPI(lifespan=lifespan)
# Configure Jinja2 templates
templates = Jinja2Templates(directory=TEMPLATES_DIR)
# Add session middleware. A secret key is required for signing the session cookie. # Add session middleware. A secret key is required for signing the session cookie.
# We can reuse our encryption key for this, but in production you might want a separate key. # We can reuse our encryption key for this, but in production you might want a separate key.
app.add_middleware(SessionMiddleware, secret_key=settings.ENCRYPTION_KEY) app.add_middleware(SessionMiddleware, secret_key=settings.ENCRYPTION_KEY)
@@ -73,12 +70,17 @@ app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
# Add the authentication router # Add the authentication router
app.include_router(auth.router) app.include_router(auth.router)
# --- Template Dependency ---
def get_templates():
return Jinja2Templates(directory=TEMPLATES_DIR)
@app.get("/") @app.get("/")
async def read_root(request: Request): async def read_root(request: Request, templates: Jinja2Templates = Depends(get_templates)):
return templates.TemplateResponse("login.html", {"request": request}) return templates.TemplateResponse("login.html", {"request": request})
@app.get("/dashboard") @app.get("/dashboard")
async def read_dashboard(request: Request, db: Session = Depends(auth.get_db)): async def read_dashboard(request: Request, db: Session = Depends(auth.get_db),
templates: Jinja2Templates = Depends(get_templates)):
# This is our protected route. It checks if a user_id exists in the session. # This is our protected route. It checks if a user_id exists in the session.
user_id = request.session.get('user_id') user_id = request.session.get('user_id')
if not user_id: if not user_id:
@@ -109,11 +111,12 @@ async def logout(request: Request):
return RedirectResponse(url="/") return RedirectResponse(url="/")
@app.get("/help/css") @app.get("/help/css")
async def css_help(request: Request): async def css_help(request: Request, templates: Jinja2Templates = Depends(get_templates)):
return templates.TemplateResponse("help_css.html", {"request": request}) return templates.TemplateResponse("help_css.html", {"request": request})
@app.get("/overlay/{user_id}") @app.get("/overlay/{user_id}")
async def read_overlay(request: Request, user_id: int, theme_override: str = None, db: Session = Depends(auth.get_db)): async def read_overlay(request: Request, user_id: int, theme_override: str = None,
db: Session = Depends(auth.get_db), templates: Jinja2Templates = Depends(get_templates)):
# This endpoint serves the overlay page. # This endpoint serves the overlay page.
user = db.query(models.User).filter(models.User.id == user_id).first() user = db.query(models.User).filter(models.User.id == user_id).first()
if not user: if not user:

View File

@@ -288,4 +288,3 @@ pre {
word-wrap: break-word; word-wrap: break-word;
font-family: monospace; font-family: monospace;
} }
}