ереименована секция services в checkOnline в config.yaml, код обновлён

This commit is contained in:
Vlad 2025-07-11 14:20:57 +03:00
parent c473db7050
commit 3cae996048
3 changed files with 7 additions and 11 deletions

View File

@ -28,4 +28,7 @@
- Проверка доступности реализована через HTTP-запросы при каждом открытии главной страницы - Проверка доступности реализована через HTTP-запросы при каждом открытии главной страницы
## [improve] Асинхронный индикатор статуса сервисов ## [improve] Асинхронный индикатор статуса сервисов
- Индикатор статуса сервисов теперь обновляется асинхронно через отдельный API-эндпоинт, не тормозит загрузку страницы - Индикатор статуса сервисов теперь обновляется асинхронно через отдельный API-эндпоинт, не тормозит загрузку страницы
## [change] Переименование секции services в checkOnline
- Секция services в config.yaml переименована в checkOnline, код обновлён

View File

@ -180,14 +180,8 @@ weather:
lon: 37.618423 lon: 37.618423
cache_ttl: 60 cache_ttl: 60
services: checkOnline:
- name: Uptime Kuma - name: Uptime Kuma
url: http://192.168.1.222:3001/ url: http://192.168.1.222:3001/
- name: PiHole X86 - name: PiHole X86
url: https://192.168.1.11/admin url: https://192.168.1.11/admin
- name: Router
url: http://192.168.1.1/
- name: Portainer
url: https://portainer.ddl.su/
- name: Grafana
url: http://192.168.1.143:3000/

View File

@ -155,8 +155,8 @@ def api_weather_forecast():
@app.route('/api/services-status', methods=['GET']) @app.route('/api/services-status', methods=['GET'])
def api_services_status(): def api_services_status():
config = load_config() config = load_config()
services = config.get('services', []) check_online = config.get('checkOnline', [])
status = check_services_status(services) if services else None status = check_services_status(check_online) if check_online else None
return jsonify({'all_services_up': status}) return jsonify({'all_services_up': status})
# config = load_config() # Удаляем глобальную переменную # config = load_config() # Удаляем глобальную переменную
@ -176,7 +176,6 @@ def index():
current_time = now.strftime('%H:%M:%S') current_time = now.strftime('%H:%M:%S')
weather = get_weather() weather = get_weather()
config = load_config() # Загружаем актуальный конфиг при каждом запросе config = load_config() # Загружаем актуальный конфиг при каждом запросе
# Убираем all_services_up из рендера
return render_template('index.html', applications=config['applications'], bookmarks=config['bookmarks'], now=now_str, current_time=current_time, 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__': if __name__ == '__main__':