Logging erweitert
This commit is contained in:
10
app.py
10
app.py
@@ -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__':
|
||||
|
Reference in New Issue
Block a user