Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/todomvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def delete(self, id):
self.todos.remove(todo)


DAO = TodoDAO()
DAO.create({"task": "Build an API"})
DAO.create({"task": "?????"})
DAO.create({"task": "profit!"})
todo_dao = TodoDAO()
todo_dao.create({"task": "Build an API"})
todo_dao.create({"task": "?????"})
todo_dao.create({"task": "profit!"})


@ns.route("/")
Expand All @@ -63,14 +63,14 @@ class TodoList(Resource):
@ns.marshal_list_with(todo)
def get(self):
"""List all tasks"""
return DAO.todos
return todo_dao.todos

@ns.doc("create_todo")
@ns.expect(todo)
@ns.marshal_with(todo, code=201)
def post(self):
"""Create a new task"""
return DAO.create(api.payload), 201
return todo_dao.create(api.payload), 201


@ns.route("/<int:id>")
Expand All @@ -83,20 +83,20 @@ class Todo(Resource):
@ns.marshal_with(todo)
def get(self, id):
"""Fetch a given resource"""
return DAO.get(id)
return todo_dao.get(id)

@ns.doc("delete_todo")
@ns.response(204, "Todo deleted")
def delete(self, id):
"""Delete a task given its identifier"""
DAO.delete(id)
todo_dao.delete(id)
return "", 204

@ns.expect(todo)
@ns.marshal_with(todo)
def put(self, id):
"""Update a task given its identifier"""
return DAO.update(id, api.payload)
return todo_dao.update(id, api.payload)


if __name__ == "__main__":
Expand Down