def post(self): """创建 Redis 实例 """ data = request.get_json() user, errors = UserSchema().load(data) if errors: return errors, 400 user.save() return {'ok': True}, 201
def put(self, object_id): """更新服务器 """ schema = UserSchema(context={'instance': g.instance}) data = request.get_json() server, errors = schema.load(data, partial=True) if errors: return errors, 400 server.save() return {'ok': True}
def get(self, object_id): """ """ data, _ = UserSchema().dump(g.instance) return data
def get(self): """获取 Redis 列表 """ servers = User.query.all() return UserSchema().dump(servers, many=True).data