Feat: Offline-Funktionalität mit IndexedDB implementiert
This commit is contained in:
27
app.py
27
app.py
@@ -330,6 +330,33 @@ def sw():
|
||||
def offline():
|
||||
return render_template('offline.html')
|
||||
|
||||
@app.route('/api/search', methods=['POST'])
|
||||
def api_search():
|
||||
"""API-Endpunkt für die Kundensuche"""
|
||||
try:
|
||||
search_params = request.get_json()
|
||||
results = search_customers(search_params)
|
||||
return jsonify(results)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/api/customers')
|
||||
def api_customers():
|
||||
"""API-Endpunkt für alle Kunden"""
|
||||
try:
|
||||
conn = sqlite3.connect(DB_FILE)
|
||||
c = conn.cursor()
|
||||
c.execute('SELECT * FROM customers')
|
||||
columns = [description[0] for description in c.description]
|
||||
results = []
|
||||
for row in c.fetchall():
|
||||
customer = dict(zip(columns, row))
|
||||
results.append(customer)
|
||||
conn.close()
|
||||
return jsonify(results)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
def init_app(app):
|
||||
"""Initialisiert die Anwendung mit allen notwendigen Einstellungen."""
|
||||
with app.app_context():
|
||||
|
Reference in New Issue
Block a user