def remove_todo(): if request.method=='GET': return redirect(url_for('home')) else: try: req = request.form _id = req.get('rm-list') List.remove_todo(_id) flash('Data Removed Successfully','warning') return redirect(url_for('home')) except Exception as error: print(error) flash('List is already empty','danger') data = list(List.find_todo()) return redirect(url_for('home'))