Add dynamic branding

This commit is contained in:
2026-01-18 20:55:27 +00:00
parent 3bdf66cb98
commit 9b2b15c570
3 changed files with 16 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import threading
import logging
import xml.etree.ElementTree as ET
from os import path
from urllib.parse import urlsplit
from re import match
import json
from requests import post
@@ -58,6 +59,18 @@ class DiscordLogger(logging.Handler):
discord_logger = DiscordLogger(environ['DISCORD_ERR_HOOK'])
app.logger.addHandler(discord_logger)
@app.context_processor
def inject_branding() -> dict:
''' Modify branding depending on the URL being used '''
req_domain = urlsplit(request.base_url).netloc.lower()
match req_domain:
case 'jakecharman.co.uk':
brand = 'Jake Charman'
case _:
brand = req_domain
return {'branding': brand}
@app.route('/')
def index() -> str:
''' Load the homepage '''