Quellcode durchsuchen

Upload files to ''

Added function to clear the list
deadtom vor 1 Tag
Ursprung
Commit
7c4a9d8a95
1 geänderte Dateien mit 11 neuen und 3 gelöschten Zeilen
  1. 11 3
      app.py

+ 11 - 3
app.py

@@ -8,7 +8,7 @@ app = Flask(__name__)
 CHECKLIST_FILE = 'checklist.json'
 
 
-# Load checklist items from a file
+# Load checklist items
 def load_checklist():
     if os.path.exists(CHECKLIST_FILE):
         with open(CHECKLIST_FILE, 'r') as file:
@@ -16,13 +16,13 @@ def load_checklist():
     return []
 
 
-# Save checklist items to a file
+# Save checklist items
 def save_checklist(items):
     with open(CHECKLIST_FILE, 'w') as file:
         json.dump(items, file)
 
 
-# In-memory storage for checklist items
+# List of checklist items
 checklist_items = load_checklist()
 
 
@@ -45,6 +45,14 @@ def check(item_id):
     return redirect(url_for('index'))
 
 
+@app.route('/clear')
+def clear():
+    global checklist_items
+    checklist_items = []  # Clear the list
+    save_checklist(checklist_items)  # Save the empty list
+    return redirect(url_for('index'))
+
+
 @app.route('/list')
 def list():
     return render_template('list.html', items=checklist_items)