Skip to content

Instantly share code, notes, and snippets.

@parthi22
Last active January 5, 2020 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parthi22/a1f83b3d4a9a1b7590c48a8624984cc6 to your computer and use it in GitHub Desktop.
Save parthi22/a1f83b3d4a9a1b7590c48a8624984cc6 to your computer and use it in GitHub Desktop.
todos file
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