version footer
This commit is contained in:
24
app.py
24
app.py
@@ -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)
|
||||
|
Reference in New Issue
Block a user