def get(self): if not redis.exists(self.path): app.logger.info("get UserList here") response_object = { "status": "success", "data": { "users": User.read() }, "message": "Get all users", } app.logger.info(response_object["message"]) redis.set(self.path, json.dumps(response_object)) else: app.logger.info("read UserList from Redis") response_object = json.loads(redis.get(self.path)) return response_object, 200
def get(self, user_id): app.logger.info("get user here") response_object = {"status": "fail", "message": "User does not exist"} try: user = User.read(user_id) if user: response_object = { "status": "success", "data": user.to_json(), "message": "Get user", } app.logger.info(response_object["message"]) return response_object, 200 else: app.logger.info(response_object["message"]) return response_object, 404 except ValueError: app.logger.info(response_object["message"]) return response_object, 404