Created
October 26, 2020 22:41
-
-
Save agustinustheo/535330ff6d4e76cb6a217b763e8c4007 to your computer and use it in GitHub Desktop.
To-do service example for Flask-FaunaDB tutorial.
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
from flask import request, jsonify | |
from helpers import todo_helper | |
def get_all_todos(): | |
try: | |
print(todo_helper.get_all_todos()) | |
return jsonify(todo_helper.get_all_todos()) | |
except Exception as ex: | |
raise ex | |
def get_todo_by_ref_id(id): | |
try: | |
return jsonify(todo_helper.get_todo_by_ref_id(id)) | |
except Exception as ex: | |
raise ex | |
def create_todo(): | |
try: | |
req_data = request.get_json() | |
return jsonify(todo_helper.create_todo(req_data)) | |
except Exception as ex: | |
raise ex | |
def update_todo(id): | |
try: | |
req_data = request.get_json() | |
return jsonify(todo_helper.update_todo(id, req_data["data"])) | |
except Exception as ex: | |
raise ex | |
def delete_todo(id): | |
try: | |
return jsonify(todo_helper.delete_todo(id)) | |
except Exception as ex: | |
raise ex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment