Compare commits
2 Commits
95ed606796
...
35ecba348b
Author | SHA1 | Date | |
---|---|---|---|
35ecba348b | |||
31b1c12dcb |
21
app.py
21
app.py
@@ -1,5 +1,5 @@
|
|||||||
from flask import Flask, render_template, request, redirect, url_for, session, abort, jsonify, g, make_response
|
from flask import Flask, render_template, request, redirect, url_for, session, jsonify, make_response
|
||||||
from flask_babel import Babel, gettext, ngettext, get_locale
|
from flask_babel import Babel, gettext, get_locale
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
@@ -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"""
|
||||||
@@ -118,7 +118,7 @@ def index():
|
|||||||
with open(log_path, 'a', encoding='utf-8') as f:
|
with open(log_path, 'a', encoding='utf-8') as f:
|
||||||
from datetime import datetime as dt
|
from datetime import datetime as dt
|
||||||
f.write(f"{dt.now().isoformat()} PAGEVIEW\n")
|
f.write(f"{dt.now().isoformat()} PAGEVIEW\n")
|
||||||
tage = werktage = wochentag = datumsrechnung = werktagsrechnung = kw_berechnen = kw_datum = wochen_monate = None
|
tage = wochentag = kw_berechnen = kw_datum = None
|
||||||
feiertage_anzahl = wochenendtage_anzahl = None
|
feiertage_anzahl = wochenendtage_anzahl = None
|
||||||
active_idx = 0
|
active_idx = 0
|
||||||
plusminus_result = None
|
plusminus_result = None
|
||||||
@@ -245,7 +245,7 @@ def index():
|
|||||||
plusminus_result = f"Datum {d.strftime('%d.%m.%Y')} {'plus' if anzahl_int>=0 else 'minus'} {abs(anzahl_int)} Monate: {result.strftime('%d.%m.%Y')}"
|
plusminus_result = f"Datum {d.strftime('%d.%m.%Y')} {'plus' if anzahl_int>=0 else 'minus'} {abs(anzahl_int)} Monate: {result.strftime('%d.%m.%Y')}"
|
||||||
except Exception:
|
except Exception:
|
||||||
plusminus_result = gettext('Ungültige Eingabe')
|
plusminus_result = gettext('Ungültige Eingabe')
|
||||||
response = make_response(render_template('index.html', tage=tage, werktage=werktage, wochentag=wochentag, plusminus_result=plusminus_result, kw_berechnen=kw_berechnen, kw_datum=kw_datum, active_idx=active_idx
|
response = make_response(render_template('index.html', tage=tage, wochentag=wochentag, plusminus_result=plusminus_result, kw_berechnen=kw_berechnen, kw_datum=kw_datum, active_idx=active_idx
|
||||||
, feiertage_anzahl=feiertage_anzahl, wochenendtage_anzahl=wochenendtage_anzahl, app_version=APP_VERSION, get_locale=get_locale
|
, feiertage_anzahl=feiertage_anzahl, wochenendtage_anzahl=wochenendtage_anzahl, app_version=APP_VERSION, get_locale=get_locale
|
||||||
))
|
))
|
||||||
return add_cache_headers(response)
|
return add_cache_headers(response)
|
||||||
@@ -321,10 +321,13 @@ def stats():
|
|||||||
session['stats_auth'] = True
|
session['stats_auth'] = True
|
||||||
return redirect(url_for('stats'))
|
return redirect(url_for('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)
|
||||||
response = make_response(render_template('stats_login.html', error=None))
|
else:
|
||||||
return add_cache_headers(response)
|
response = make_response(render_template('stats_login.html', error=None))
|
||||||
|
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))
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
Flask==3.0.0
|
Flask==3.1.1
|
||||||
numpy==1.26.4
|
numpy==2.3.2
|
||||||
python-dateutil==2.9.0.post0
|
python-dateutil==2.9.0.post0
|
||||||
requests==2.31.0
|
requests==2.32.4
|
||||||
Flask-Babel==4.0.0
|
Flask-Babel==4.0.0
|
||||||
|
pytest==8.4.1
|
Reference in New Issue
Block a user