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