Last active
January 5, 2020 03:29
-
-
Save parthi22/a1f83b3d4a9a1b7590c48a8624984cc6 to your computer and use it in GitHub Desktop.
todos file
This file contains 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_restful import Resource | |
todos = [ | |
{ | |
"id": 1, | |
"item": "Create sample app", | |
"status": "Completed" | |
}, | |
{ | |
"id": 2, | |
"item": "Deploy in Heroku", | |
"status": "Open" | |
}, | |
{ | |
"id": 3, | |
"item": "Publish", | |
"status": "Open" | |
} | |
] | |
class Todo(Resource): | |
def get(self, id): | |
for todo in todos: | |
if(id == todo["id"]): | |
return todo, 200 | |
return "Item not found for the id: {}".format(id), 404 | |
def put(self, id): | |
for todo in todos: | |
if(id == todo["id"]): | |
todo["item"] = request.form["data"] | |
todo["status"] = "Open" | |
return todo, 200 | |
return "Item not found for the id: {}".format(id), 404 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment