Version 1.2.15: Autovervollständigung für Orte

This commit is contained in:
2025-03-21 11:25:28 +01:00
parent 6283ccff6d
commit f626cd52fd
4 changed files with 133 additions and 2 deletions

28
app.py
View File

@@ -18,7 +18,7 @@ logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Version der Anwendung
VERSION = "1.2.14"
VERSION = "1.2.15"
# Pfad zur Datenbank
DB_FILE = 'data/customers.db'
@@ -374,6 +374,32 @@ def get_fachrichtungen():
logger.error(f"Fehler beim Abrufen der Fachrichtungen: {str(e)}")
return jsonify([])
@app.route('/api/orte')
def get_orte():
try:
search_term = request.args.get('q', '').lower()
conn = get_db_connection()
c = conn.cursor()
# Hole alle eindeutigen Orte, die mit dem Suchbegriff übereinstimmen
c.execute('''
SELECT DISTINCT ort
FROM customers
WHERE ort IS NOT NULL
AND ort != ''
AND LOWER(ort) LIKE ?
ORDER BY ort
LIMIT 10
''', (f'%{search_term}%',))
orte = [row[0] for row in c.fetchall()]
conn.close()
return jsonify(orte)
except Exception as e:
logger.error(f"Fehler beim Abrufen der Orte: {str(e)}")
return jsonify([])
def init_app(app):
"""Initialisiert die Anwendung mit allen notwendigen Einstellungen."""
with app.app_context():