def post(self, **auth): parser = reqparse.RequestParser() parser.add_argument('data', type=dict, required=True, location='json') args = parser.parse_args() rst = register_user_account(args, global_var) return encoding_resp_utf8(rst)
def get(self, comment_id, **auth): parser = reqparse.RequestParser() parser.add_argument("data", type=dict, required=False, location="json") args = parser.parse_args() res = get_one_comment(args, global_var, comment_id) return encoding_resp_utf8(res)
def get(self, **auth): """ 请求算法导论的目录 示例格式: http://localhost:5000/api/v1/introduction_to_algorithms/catalog """ parser = reqparse.RequestParser() args = parser.parse_args() # db = global_var["db"] res = get_catalog_json(args) return encoding_resp_utf8(res)
def get(self, **auth): parser = reqparse.RequestParser() # parser.add_argument('page', type=int, required=False, location='args') # parser.add_argument('pageSize', type=int, required=False, location='args') parser.add_argument('keyword', type=str, required=False, location='args') args = parser.parse_args() # db = global_var["db"] res = test_func(args) return encoding_resp_utf8(res)
def post(self, **auth): """ 创建一条评论 ---------- <1> 3是默认普通用户的role_id, 默认有评论的权限 <2> 每天又评论数量限制, 被定义在 global_var["daily_comment_creation_max_threshold"] 中. <3> 是否超过每日限制, 可以根据 global_var["today_already_created_comment_count"] 来判断 """ parser = reqparse.RequestParser() parser.add_argument("data", type=dict, required=False, location="json") args = parser.parse_args() res = create_comment(args, global_var) return encoding_resp_utf8(res)
def get(self, **auth): parser = reqparse.RequestParser() parser.add_argument('page', type=int, required=False, location='args') parser.add_argument('pageSize', type=int, required=False, location='args') parser.add_argument('keyword', type=str, required=False, location='args') args = parser.parse_args() res = get_comment_list(args, global_var) return encoding_resp_utf8(res)
def get(self): try: verify_jwt_in_request() except Exception as e: print(e) # 这里的return结果,不要轻易修改. return { 'errorCode': 'BAUTH_TOKEN_MISSING', 'errorMessage': '无效 access token' }, 401 # return {'errorCode': 'Unauthorized Access Token', 'errorMessage': '无效的access token'}, 401 current_user = get_jwt_identity() db = global_var['db'] rst = getCurrentUser(db, current_user) return encoding_resp_utf8(rst)
def get(self, **auth): """ part - 1-7部分 chapter - 1-35 章 section - 每一章的第xx小节 示例, 请求 "第1部分 第4章 第3小节" 的格式: http://localhost:5000/api/v1/introduction_to_algorithms/page?part=1&chapter=4§ion=3 """ parser = reqparse.RequestParser() parser.add_argument('part', type=str, required=False, location='args') parser.add_argument('chapter', type=str, required=False, location='args') parser.add_argument('section', type=str, required=False, location='args') args = parser.parse_args() # db = global_var["db"] res = get_md_page(args) return encoding_resp_utf8(res)
def post(self): parser = reqparse.RequestParser() parser.add_argument('id', type=str, required=True, location='json') args = parser.parse_args() rst = LoginUtils.logout(global_var['db'], args) return encoding_resp_utf8(rst)