version footer

This commit is contained in:
Mateusz Gruszczyński
2025-09-23 10:37:02 +02:00
parent a5bf017c30
commit c2c7adf950
13 changed files with 113 additions and 80 deletions

24
app.py
View File

@@ -147,6 +147,25 @@ WEBP_SAVE_PARAMS = {
"quality": 95, # tylko jeśli lossless=False
}
def build_fingerprint(paths):
h = hashlib.sha256()
for base in paths:
if not os.path.exists(base):
continue
for root, _, files in os.walk(base):
for f in sorted(files):
p = os.path.join(root, f)
try:
with open(p, "rb") as fh:
h.update(fh.read())
except Exception:
pass
return h.hexdigest()[:8]
APP_VERSION = f"{datetime.now():%Y.%m.%d}+{build_fingerprint(['templates','static','app.py'])}"
app.config['APP_VERSION'] = APP_VERSION
db = SQLAlchemy(app)
socketio = SocketIO(app, async_mode="eventlet")
login_manager = LoginManager(app)
@@ -1320,6 +1339,11 @@ def load_user(user_id):
return db.session.get(User, int(user_id))
@app.context_processor
def inject_version():
return {'APP_VERSION': app.config['APP_VERSION']}
@app.context_processor
def inject_time():
return dict(time=time)