class Users(Resource): @use_args(UserSchema(many=True)) def post(self, args): UserController().addUser(args) return UserSchema(many=True).dump(args).data, 201 def get(self): users = UserController().getUsers() return UserSchema(many=True).dump(users).data, 201
class User(Resource): def get(self, id): user = UserController().getUserByID(id) if user: return UserSchema().dump(user).data return 'User not found', 404 @use_args(UserSchema()) def put(self, args): UserController().updateUser() return UserSchema().dump(args).data, 200 def delete(self, id): UserController().deleteUser(id) return 'User removed', 200
class User( Resource ): schema = UserSchema() def get( self, id ): return self.schema.dump( get_user_by_id( user_id = id ) ), 200 def post( self ): pass def put( self ): pass def delete( self ): pass
def get(self, id): user = UserController().getUserByID(id) if user: return UserSchema().dump(user).data return 'User not found', 404
def get(self): users = UserController().getUsers() return UserSchema(many=True).dump(users).data, 201
def post(self, args): UserController().addUser(args) return UserSchema(many=True).dump(args).data, 201
def put(self, args): UserController().updateUser() return UserSchema().dump(args).data, 200