Update app.py
This commit is contained in:
11
app.py
11
app.py
@ -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():
|
||||
|
||||
Reference in New Issue
Block a user