diff --git a/changelog.md b/changelog.md index 7b5526b..695bb37 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ - Встроен Monaco Editor для YAML с подсветкой синтаксиса, проверкой ошибок и возможностью увеличивать окно редактора - Добавлен вывод температуры и облачности с weatherapi.com, настройки (api_key, lat, lon, cache_ttl) вынесены в config.yaml - Поддержка настройки времени кэширования погоды через weather.cache_ttl (минуты, по умолчанию 60) +- В шапке вместо приветствия теперь крупно текущее время, дата на русском ## [init] Стартовая инициализация структуры Flask-приложения - Создана структура каталогов: templates/, static/ diff --git a/main.py b/main.py index a5cb7f4..ce40e9b 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ from datetime import datetime import os import requests import time +import locale app = Flask(__name__) @@ -81,9 +82,15 @@ config = load_config() @app.route('/') def index(): - now = datetime.now().strftime('%A, %d %B %Y - %H:%M:%S') + try: + locale.setlocale(locale.LC_TIME, 'ru_RU.UTF-8') + except: + pass + now = datetime.now() + now_str = now.strftime('%A, %d %B %Y').capitalize() + current_time = now.strftime('%H:%M:%S') weather = get_weather() - return render_template('index.html', applications=config['applications'], bookmarks=config['bookmarks'], now=now, weather=weather) + return render_template('index.html', applications=config['applications'], bookmarks=config['bookmarks'], now=now_str, current_time=current_time, weather=weather) if __name__ == '__main__': app.run(debug=True, host='0.0.0.0') diff --git a/templates/index.html b/templates/index.html index 3218c82..3871d56 100644 --- a/templates/index.html +++ b/templates/index.html @@ -15,10 +15,11 @@
-

{{ now }}

- Go to Settings -

Good morning!

+
+ {{ current_time }} + {{ now }} +