|  | @@ -1,5 +1,6 @@
 | 
	
		
			
				|  |  | -from flask import Flask, render_template, Blueprint, request, redirect, url_for
 | 
	
		
			
				|  |  | +from flask import Flask, render_template, Blueprint, request, redirect, url_for, current_app
 | 
	
		
			
				|  |  |  from datetime import timezone
 | 
	
		
			
				|  |  | +import json
 | 
	
		
			
				|  |  |  import os
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  clbp = Blueprint('checklist', __name__)
 | 
	
	
		
			
				|  | @@ -10,7 +11,7 @@ def save_checklist(list_items):  # Save checklist items
 | 
	
		
			
				|  |  |      list_file = os.path.join(current_app.instance_path, 'list.py')
 | 
	
		
			
				|  |  |      try:
 | 
	
		
			
				|  |  |          with open(list_file, 'w') as f:
 | 
	
		
			
				|  |  | -            f.write(f'LIST = [{new_list}]')
 | 
	
		
			
				|  |  | +            f.write(f'LIST = {new_list}')
 | 
	
		
			
				|  |  |          f.close
 | 
	
		
			
				|  |  |          current_app.config.from_pyfile('list.py', silent=True)  # Reread the list into the app
 | 
	
		
			
				|  |  |      except Exception as sclerror:
 | 
	
	
		
			
				|  | @@ -19,34 +20,45 @@ def save_checklist(list_items):  # Save checklist items
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @clbp.route('/', methods=['GET', 'POST'])
 | 
	
		
			
				|  |  |  def index():
 | 
	
		
			
				|  |  | -    checklist_items = current_app.list['LIST']
 | 
	
		
			
				|  |  | +    checklist_items = current_app.config['LIST']
 | 
	
		
			
				|  |  |      if request.method == 'POST':
 | 
	
		
			
				|  |  | +        checklist_items = current_app.config['LIST']
 | 
	
		
			
				|  |  |          item = request.form.get('item')
 | 
	
		
			
				|  |  | +        print(checklist_items)
 | 
	
		
			
				|  |  |          if item:
 | 
	
		
			
				|  |  | -            checklist_items.append({'name': item, 'checked': False})
 | 
	
		
			
				|  |  | +            checklist_items.append({'name': item, 'checked': 'no'})
 | 
	
		
			
				|  |  |              save_checklist(checklist_items)  # Save to file after adding
 | 
	
		
			
				|  |  | -        return redirect(url_for('index'))
 | 
	
		
			
				|  |  | +        return redirect(url_for('checklist.index'))
 | 
	
		
			
				|  |  |      return render_template('index.html', items=checklist_items)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @clbp.route('/check/<int:item_id>')
 | 
	
		
			
				|  |  |  def check(item_id):
 | 
	
		
			
				|  |  | -    checklist_items = current_app.list['LIST']
 | 
	
		
			
				|  |  | +    checklist_items = current_app.config['LIST']
 | 
	
		
			
				|  |  |      if 0 <= item_id < len(checklist_items):
 | 
	
		
			
				|  |  | -        checklist_items[item_id]['checked'] = not checklist_items[item_id]['checked']
 | 
	
		
			
				|  |  | +        checklist_items[item_id]['checked'] = 'yes'
 | 
	
		
			
				|  |  |          save_checklist(checklist_items)  # Save to file after checking
 | 
	
		
			
				|  |  | -    return redirect(url_for('index'))
 | 
	
		
			
				|  |  | +    return redirect(url_for('checklist.index'))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@clbp.route('/uncheck/<int:item_id>')
 | 
	
		
			
				|  |  | +def uncheck(item_id):
 | 
	
		
			
				|  |  | +    checklist_items = current_app.config['LIST']
 | 
	
		
			
				|  |  | +    if 0 <= item_id < len(checklist_items):
 | 
	
		
			
				|  |  | +        checklist_items[item_id]['checked'] = 'no'
 | 
	
		
			
				|  |  | +        save_checklist(checklist_items)  # Save to file after checking
 | 
	
		
			
				|  |  | +    return redirect(url_for('checklist.index'))
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @clbp.route('/clear')
 | 
	
		
			
				|  |  |  def clear():
 | 
	
		
			
				|  |  | -    checklist_items = current_app.list['LIST']
 | 
	
		
			
				|  |  | +    checklist_items = current_app.config['LIST']
 | 
	
		
			
				|  |  |      checklist_items = []  # Clear the list
 | 
	
		
			
				|  |  |      save_checklist(checklist_items)  # Save the empty list
 | 
	
		
			
				|  |  | -    return redirect(url_for('index'))
 | 
	
		
			
				|  |  | +    return redirect(url_for('checklist.index'))
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @clbp.route('/list')
 | 
	
		
			
				|  |  |  def list():
 | 
	
		
			
				|  |  | -    checklist_items = current_app.list['LIST']
 | 
	
		
			
				|  |  | +    checklist_items = current_app.config['LIST']
 | 
	
		
			
				|  |  |      return render_template('list.html', items=checklist_items)
 |