Skip to content

Instantly share code, notes, and snippets.

@agusrichard
Created April 4, 2021 09:48
Show Gist options
  • Select an option

  • Save agusrichard/d4b07af65bf77828ba9035a6c0386c36 to your computer and use it in GitHub Desktop.

Select an option

Save agusrichard/d4b07af65bf77828ba9035a6c0386c36 to your computer and use it in GitHub Desktop.
@todo_blueprint.route('/update/<int:todo_id>', methods=['POST'])
@token_required
def update_todo(todo_id):
try:
user_data = session['user_data']
client = TodoClient()
result_update = client.update_todo(todo_id, request.form['title'], request.form['description'])
result_get = client.get_todo(todo_id, user_data.get('ID'))
data = json.loads(result_get.data)
return render_template('todo/item.html', todo=data)
except Exception as error:
return render_template('todo/item.html', error=str(error))
@todo_blueprint.route('/delete/<int:todo_id>', methods=['GET'])
@token_required
def delete_todo(todo_id):
try:
client = TodoClient()
result = client.delete_todo(todo_id)
return redirect(url_for('todo_blueprint.get_todos'))
except Exception as error:
return render_template('todo/item.html', error=str(error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment