Пример #1
0
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
Пример #2
0
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
Пример #3
0
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
Пример #4
0
 def get(self, id):
     user = UserController().getUserByID(id)
     if user:
         return UserSchema().dump(user).data
     return 'User not found', 404
Пример #5
0
 def get(self):
     users = UserController().getUsers()
     return UserSchema(many=True).dump(users).data, 201
Пример #6
0
 def post(self, args):
     UserController().addUser(args)
     return UserSchema(many=True).dump(args).data, 201
Пример #7
0
 def put(self, args):
     UserController().updateUser()
     return UserSchema().dump(args).data, 200