Fix stats route UnboundLocalError and bump version to 1.4.14

This commit is contained in:
2025-08-03 12:59:41 +02:00
parent 31b1c12dcb
commit 35ecba348b

5
app.py
View File

@@ -20,7 +20,7 @@ app.config['BABEL_TRANSLATION_DIRECTORIES'] = 'translations'
babel = Babel() babel = Babel()
# Version der App # Version der App
APP_VERSION = "1.4.13" APP_VERSION = "1.4.14"
def add_cache_headers(response): def add_cache_headers(response):
"""Fügt Cache-Control-Header hinzu, die den Back-Forward-Cache ermöglichen""" """Fügt Cache-Control-Header hinzu, die den Back-Forward-Cache ermöglichen"""
@@ -323,8 +323,11 @@ def stats():
else: else:
response = make_response(render_template('stats_login.html', error='Falsches Passwort!')) response = make_response(render_template('stats_login.html', error='Falsches Passwort!'))
return add_cache_headers(response) return add_cache_headers(response)
else:
response = make_response(render_template('stats_login.html', error=None)) response = make_response(render_template('stats_login.html', error=None))
return add_cache_headers(response) return add_cache_headers(response)
# Wenn authentifiziert, zeige Dashboard
log_path = os.path.join('log', 'pageviews.log') log_path = os.path.join('log', 'pageviews.log')
pageviews, func_counts, func_counts_hourly, impressions_per_day, impressions_per_hour, api_counts, api_counts_hourly = parse_log_stats(log_path) pageviews, func_counts, func_counts_hourly, impressions_per_day, impressions_per_hour, api_counts, api_counts_hourly = parse_log_stats(log_path)
response = make_response(render_template('stats_dashboard.html', pageviews=pageviews, func_counts=func_counts, func_counts_hourly=func_counts_hourly, impressions_per_day=impressions_per_day, impressions_per_hour=impressions_per_hour, api_counts=api_counts, api_counts_hourly=api_counts_hourly)) response = make_response(render_template('stats_dashboard.html', pageviews=pageviews, func_counts=func_counts, func_counts_hourly=func_counts_hourly, impressions_per_day=impressions_per_day, impressions_per_hour=impressions_per_hour, api_counts=api_counts, api_counts_hourly=api_counts_hourly))