Version 1.2.16: Verbesserte Darstellung der Suchergebnisse und Code-Organisation

This commit is contained in:
2025-03-21 11:50:54 +01:00
parent 3a317de8f0
commit 2a33fc45de
5 changed files with 477 additions and 36 deletions

14
app.py
View File

@@ -13,13 +13,12 @@ import sqlite3
from functools import wraps
app = Flask(__name__, static_folder='static')
app.secret_key = os.getenv('SECRET_KEY', 'default-secret-key')
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', 'dev')
app.config['ALLOWED_IP_RANGES'] = os.getenv('ALLOWED_IP_RANGES', '192.168.0.0/16,10.0.0.0/8').split(',')
app.config['VERSION'] = '1.2.16'
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Version der Anwendung
VERSION = "1.2.15"
# Pfad zur Datenbank
DB_FILE = 'data/customers.db'
@@ -28,7 +27,6 @@ load_dotenv()
# Statisches Passwort aus der .env Datei
STATIC_PASSWORD = os.getenv('LOGIN_PASSWORD', 'default-password')
ALLOWED_IP_RANGES = os.getenv('ALLOWED_IP_RANGES', '').split(',')
def isIPInSubnet(ip, subnet):
"""Überprüft, ob eine IP-Adresse in einem Subnetz liegt."""
@@ -184,7 +182,7 @@ def login():
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
# Überprüfe, ob die Client-IP in einem der erlaubten Bereichen liegt
is_allowed = any(isIPInSubnet(client_ip, range.strip()) for range in ALLOWED_IP_RANGES if range.strip())
is_allowed = any(isIPInSubnet(client_ip, range.strip()) for range in app.config['ALLOWED_IP_RANGES'] if range.strip())
if is_allowed:
logger.info(f"Client-IP {client_ip} ist in einem erlaubten Bereich, automatischer Login")
@@ -213,8 +211,8 @@ def index():
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
logger.info(f"Client-IP: {client_ip}")
logger.info(f"Erlaubte IP-Bereiche: {ALLOWED_IP_RANGES}")
return render_template('index.html', allowed_ip_ranges=','.join(ALLOWED_IP_RANGES), version=VERSION)
logger.info(f"Erlaubte IP-Bereiche: {app.config['ALLOWED_IP_RANGES']}")
return render_template('index.html', allowed_ip_ranges=','.join(app.config['ALLOWED_IP_RANGES']), version=app.config['VERSION'])
@app.route('/search', methods=['GET', 'POST'])
def search():