new options

This commit is contained in:
Mateusz Gruszczyński
2025-11-03 10:18:10 +01:00
parent acef7eb610
commit df70118653
5 changed files with 355 additions and 139 deletions

20
app.py
View File

@@ -1,14 +1,15 @@
from flask import Flask, render_template, render_template_string
import configparser
import os
import sys
import ssl
import configparser
from flask import Flask, render_template, render_template_string
from routes.main_routes import main_bp
from routes.edit_routes import edit_bp
from utils.stats_utils import fetch_haproxy_stats, parse_haproxy_stats
from auth.auth_middleware import setup_auth
from log_parser import parse_log_file
import os
import sys
from utils.haproxy_config import update_haproxy_config, is_frontend_exist, count_frontends_and_backends
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -73,23 +74,23 @@ try:
certificate_path = config2.get('ssl', 'certificate_path')
private_key_path = config2.get('ssl', 'private_key_path')
else:
print(f"[APP] No [ssl] section in {SSL_INI}", flush=True)
print(f"[APP] No [ssl] section in {SSL_INI}", flush=True)
sys.exit(1)
if not os.path.exists(certificate_path):
print(f"[APP] Certificate not found: {certificate_path}", flush=True)
print(f"[APP] Certificate not found: {certificate_path}", flush=True)
sys.exit(1)
if not os.path.exists(private_key_path):
print(f"[APP] Private key not found: {private_key_path}", flush=True)
print(f"[APP] Private key not found: {private_key_path}", flush=True)
sys.exit(1)
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
ssl_context.load_cert_chain(certfile=certificate_path, keyfile=private_key_path)
print(f"[APP] SSL context loaded", flush=True)
print(f"[APP] SSL context loaded", flush=True)
except Exception as e:
print(f"[APP] SSL error: {e}", flush=True)
print(f"[APP] SSL error: {e}", flush=True)
sys.exit(1)
@@ -105,7 +106,6 @@ def display_logs():
parsed_entries = parse_log_file(log_file_path)
return render_template('logs.html', entries=parsed_entries)
@app.route('/home')
def home():
frontend_count, backend_count, acl_count, layer7_count, layer4_count = count_frontends_and_backends()