fixxed error with jinja template and today variable
This commit is contained in:
parent
cae805fb65
commit
e5d5d74523
15
app.py
15
app.py
@ -291,19 +291,20 @@ def admin_logs(date=None):
|
|||||||
if date is None:
|
if date is None:
|
||||||
date = datetime.now().strftime('%d')
|
date = datetime.now().strftime('%d')
|
||||||
|
|
||||||
today = datetime.now().strftime('%Y-%m')
|
today = datetime.now().strftime('%Y-%m') # ← Hier definieren!
|
||||||
|
|
||||||
log_dir = os.path.join(LOG_DIR, today)
|
log_dir = os.path.join(LOG_DIR, today)
|
||||||
|
|
||||||
if not os.path.exists(log_dir):
|
if not os.path.exists(log_dir):
|
||||||
return render_template('admin_logs.html', logs="Keine Logs für diesen Tag.", date=date, dates=[])
|
return render_template('admin_logs.html', logs="Keine Logs für diesen Tag.", date=date, dates=[], today=today)
|
||||||
|
|
||||||
# Verfügbare Tage (alle .log-Dateien im Monatsordner)
|
# Verfügbare Tage ...
|
||||||
dates = sorted([
|
dates = sorted([
|
||||||
f.split('-')[0] for f in os.listdir(log_dir)
|
f.split('-')[0] for f in os.listdir(log_dir)
|
||||||
if f.endswith('-info.log') or f.endswith('-error.log')
|
if f.endswith('-info.log') or f.endswith('-error.log')
|
||||||
], reverse=True)
|
], reverse=True)
|
||||||
|
|
||||||
# Logs des gewählten Tages laden
|
# Logs laden ...
|
||||||
info_path = os.path.join(log_dir, f"{date}-info.log")
|
info_path = os.path.join(log_dir, f"{date}-info.log")
|
||||||
error_path = os.path.join(log_dir, f"{date}-error.log")
|
error_path = os.path.join(log_dir, f"{date}-error.log")
|
||||||
|
|
||||||
@ -317,7 +318,11 @@ def admin_logs(date=None):
|
|||||||
|
|
||||||
log_content = "\n\n".join(logs) if logs else "Keine Logs für diesen Tag."
|
log_content = "\n\n".join(logs) if logs else "Keine Logs für diesen Tag."
|
||||||
|
|
||||||
return render_template('admin_logs.html', logs=log_content, date=date, dates=dates)
|
return render_template('admin_logs.html',
|
||||||
|
logs=log_content,
|
||||||
|
date=date,
|
||||||
|
dates=dates,
|
||||||
|
today=today) # ← Hier mit übergeben!
|
||||||
|
|
||||||
|
|
||||||
@app.route('/configs/<path:filename>')
|
@app.route('/configs/<path:filename>')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user