def process_multiple_readings(): # api_response = ApiResponse() flapp.logger.info('Received %s bytes of compressed data' % sys.getsizeof(request.data)) decompressed = zlib.decompress(request.data) response = ApiResponse(request) try: request_json = json.loads(decompressed) except Exception, e: print e
def post(self, topic_id, post_id) -> ApiResponse: kwargs = self.parsed_args comment = CommentHandler(topic_id=topic_id, post_id=post_id).create_comment(**kwargs) return ApiResponse().ok(comment)
def put(self, user_id) -> ApiResponse: kwargs = self.parsed_args user = UserHandler(user_id).update(**kwargs) return ApiResponse().ok(user)
def put(self, topic_id) -> ApiResponse: kwargs = self.parsed_args topic = TopicHandler(topic_id).update_topic(**kwargs) return ApiResponse().ok(topic)
def get_api_response(response): json_dict = json.loads(response.text) api_response = ApiResponse(**json_dict) return api_response
def post(self) -> ApiResponse: # 新增一个用户 kwargs = self.parsed_args user = UserHandler.create(**kwargs) return ApiResponse().ok(user)
def delete(self, root_topic_id) -> ApiResponse: return ApiResponse().ok(RootTopicHandler(root_topic_id).delete_topic())
def get(self, topic_id) -> ApiResponse: kwargs = self.parsed_args posts = PostHandler(topic_id).get_posts(**kwargs) return ApiResponse().ok(posts)
def get(self, root_topic_id) -> ApiResponse: return ApiResponse().ok(RootTopicHandler(root_topic_id).get_topic())
def put(self, root_topic_id) -> ApiResponse: kwargs = self.parsed_args return ApiResponse().ok(RootTopicHandler(root_topic_id).update_topic(**kwargs))
def post(self) -> ApiResponse: kwargs = self.parsed_args topic = TopicHandler().create_topic(**kwargs) return ApiResponse().ok(topic)
def get(self) -> ApiResponse: topics = TopicHandler().get_topics() return ApiResponse().ok(topics)
def delete(self, topic_id) -> ApiResponse: TopicHandler(topic_id).delete_topic() return ApiResponse().ok()
def get(self, topic_id, post_id) -> ApiResponse: post = PostHandler(topic_id=topic_id, post_id=post_id).get_post() return ApiResponse().ok(post)
def get(self): return ApiResponse().ok(RootTopicHandler().get_topics())
def delete(self, topic_id, post_id) -> ApiResponse: PostHandler(topic_id, post_id).delete_post() return ApiResponse().ok()
def post(self): kwargs = self.parsed_args return ApiResponse().ok(RootTopicHandler().create_topic(**kwargs))
def post(self, topic_id) -> ApiResponse: kwargs = self.parsed_args post = PostHandler(topic_id).create_post(**kwargs) return ApiResponse().ok(post)
def get(self, topic_id, post_id, comment_id) -> ApiResponse: comment = CommentHandler(topic_id, post_id, comment_id).get_comment() return ApiResponse().ok(comment)
def get(self) -> ApiResponse: # 获取所有的用户 users = UserHandler.get_users() return ApiResponse().ok(users)
def delete(self, topic_id, post_id, comment_id) -> ApiResponse: CommentHandler(topic_id, post_id, comment_id).delete_comment() return ApiResponse().ok()
def get(self, user_id) -> ApiResponse: user = UserHandler(user_id).get_user() return ApiResponse().ok(user)
def get(self, topic_id, post_id) -> ApiResponse: kwargs = self.parsed_args comments = CommentHandler(topic_id=topic_id, post_id=post_id).get_comments(**kwargs) return ApiResponse().ok(comments)
def delete(self, user_id) -> ApiResponse: UserHandler(user_id).delete() return ApiResponse().ok()
def get(self, topic_id) -> ApiResponse: topic = TopicHandler(topic_id).get_topic() return ApiResponse().ok(topic)