def put(self, id): parsed_args = parser.parse_args() hub = db_session.query(Hub).filter(Hub.id == id).first() if not hub: abort(404, message="Hub doesn't exist".format(id)) hub.name = parsed_args['name'] db_session.add(hub) db_session.commit() return hub.as_dict(), 201
def post(self): parsed_args = parser.parse_args() hub = Hub(name=parsed_args['name']) db_session.add(hub) db_session.commit() return hub.as_dict(), 201