def delete(self, id): student = Student.find(id) if student is None: return {'code': 400, 'message': 'School data not found'}, 400 Student.delete(id) return { 'code': 200, 'message': 'Student data successfully deleted' }, 200
def put(self, id): data = StudentResource.parser.parse_args() student = Student.find(id) if student is None: return {'code': 400, 'message': 'Student data not found'}, 400 student.name = data['name'] student.school_id = data['school_id'] student.save() return { 'code': 200, 'message': 'Student data successfully updated' }, 200
def get(self, id): student = Student.find(id) if student is None: return {'code': 404, 'message': 'Student data not found'}, 404 return {'code': 200, 'student': student._json()}, 200