Logging erweitert

This commit is contained in:
2025-07-23 11:29:47 +02:00
parent 09cf3706e4
commit 5c4f419895
2 changed files with 37 additions and 1 deletions

10
app.py
View File

@@ -147,15 +147,23 @@ def stats():
log_path = os.path.join('log', 'pageviews.log')
pageviews = 0
func_counts = {}
impressions_per_day = {}
if os.path.exists(log_path):
with open(log_path, encoding='utf-8') as f:
for line in f:
if 'PAGEVIEW' in line:
pageviews += 1
# Datum extrahieren (YYYY-MM-DD)
try:
date = line[:10]
if len(date) == 10 and date[4] == '-' and date[7] == '-':
impressions_per_day[date] = impressions_per_day.get(date, 0) + 1
except Exception:
pass
elif 'FUNC:' in line:
func = line.split('FUNC:')[1].strip()
func_counts[func] = func_counts.get(func, 0) + 1
return render_template('stats_dashboard.html', pageviews=pageviews, func_counts=func_counts)
return render_template('stats_dashboard.html', pageviews=pageviews, func_counts=func_counts, impressions_per_day=impressions_per_day)
if __name__ == '__main__':