Created
April 4, 2021 09:48
-
-
Save agusrichard/d4b07af65bf77828ba9035a6c0386c36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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