Update app.py

This commit is contained in:
2025-07-04 22:46:31 +02:00
parent 0000bc9ea0
commit a34ade4409

11
app.py
View File

@ -34,6 +34,17 @@ js_bundle = assets.register('js_all', Bundle(
# Initialize the translation system
init_app(app)
# WWW to non-WWW redirect
@app.before_request
def redirect_www():
"""Redirect www subdomain to non-www version"""
if request.host.startswith('www.'):
# Get the non-www version of the host
non_www_host = request.host.replace('www.', '', 1)
# Preserve the full URL including path and query parameters
url = request.url.replace(request.host, non_www_host)
return redirect(url, code=301)
# Context processor to make variables available in templates
@app.context_processor
def inject_conf_var():