шапке вместо приветствия теперь крупно текущее время, дата на русском
This commit is contained in:
parent
e89fd52a89
commit
49fd9ac916
@ -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/
|
||||
|
||||
11
main.py
11
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')
|
||||
|
||||
@ -15,10 +15,11 @@
|
||||
<div class="Layout_Container__HIHX7">
|
||||
<div><input type="text" class="SearchBar_SearchBar__MQiwu" placeholder="Поиск..."></div>
|
||||
<header class="Header_Header__GCJdR">
|
||||
<p>{{ now }}</p>
|
||||
<a class="Header_SettingsLink__9QdDu" href="/settings">Go to Settings</a>
|
||||
<span class="Header_HeaderMain__oLoBB">
|
||||
<h1>Good morning!</h1>
|
||||
<div style="display:flex; flex-direction:column; align-items:flex-start; gap:4px;">
|
||||
<span style="font-size:2.2em; font-weight:bold;">{{ current_time }}</span>
|
||||
<span style="font-size:1.1em;">{{ now }}</span>
|
||||
</div>
|
||||
<div class="WeatherWidget_WeatherWidget__3XlYt">
|
||||
<div><canvas id="weather-icon" width="50" height="50"></canvas></div>
|
||||
<div class="WeatherWidget_WeatherDetails__1y3CA">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user