From 64fba789d06d1af3680d51ea360387658c1f4485 Mon Sep 17 00:00:00 2001 From: Noretsa Date: Wed, 15 Nov 2023 13:57:17 +0300 Subject: [PATCH] add auto datetime and year --- __init__.py | 6 ++++++ templates/new_layout.html | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index 548d910..22ddc25 100644 --- a/__init__.py +++ b/__init__.py @@ -1,5 +1,6 @@ from flask import Flask, render_template from flask_sqlalchemy import SQLAlchemy +from datetime import datetime app = Flask(__name__, static_folder='static', static_url_path='') @@ -30,6 +31,11 @@ menu = [ ] +@app.context_processor +def inject_now(): + return {'now': datetime.utcnow()} + + @app.route("/") @app.route("/home") def home(): diff --git a/templates/new_layout.html b/templates/new_layout.html index 8edec8c..5efd3ec 100644 --- a/templates/new_layout.html +++ b/templates/new_layout.html @@ -153,7 +153,7 @@
- © {{ moment().format('YYYY') }} Copyright: + © {{ now.year }} Copyright: klintorg.ru