Exemplo n.º 1
0
 def view_all():
     if request.method == "GET":
         # 先鉴权
         token = request.json.get("token")
         if gen_token.authentication(token) and not pNc.if_ban(token):
             post_list = pNc.get_recent20_post()
             return dict(success=True, message="200", posts=post_list)
         else:
             return dict(success=False,
                         message="Invalid token.",
                         errorCode=3)
Exemplo n.º 2
0
 def delete_something():
     if request.method == "DELETE":
         # 先鉴权
         token = request.json.get("token")
         if gen_token.authentication(token) and not pNc.if_ban(token):
             reply_id = request.args.get("reply_id")
             pNc.delete(reply_id, "C_COMMENT", "ID")
             return dict(success=True, message="200")
         else:
             return dict(success=False,
                         message="Invalid token.",
                         errorCode=3)
Exemplo n.º 3
0
 def love_death_elective():
     if request.method == "POST":
         # 先鉴权
         token = request.json.get("token")
         if gen_token.authentication(token) and not pNc.if_ban(token):
             lecture = request.args["lecture"]
             if_sign, test_form, if_hw, if_touch_fish, general, comment =\
                 request.json["sign"], request.json["test"], request.json["hw"], request.json["fish"], request.json["general"], request.json["comment"]
             if comment_elective.comment_elective(if_sign, test_form, if_hw,
                                                  if_touch_fish, lecture,
                                                  comment, general):
                 return dict(success=True, message="200")
         else:
             return dict(success=False,
                         message="Invalid token.",
                         errorCode=3)
Exemplo n.º 4
0
 def comment():
     if request.method == "POST":
         # 先鉴权
         token = request.json.get("token")
         if gen_token.authentication(token) and not pNc.if_ban(token):
             post_id = request.args.get("post_id")
             print("post_id is", post_id)
             p_comment = request.json.get("content")
             status = pNc.comment(p_comment, token, post_id)
             if status == 1:
                 return dict(success=True,
                             message="200 - Comment successfully sent.")
             elif status == 2:
                 return dict(success=False,
                             message="404 - post not found",
                             errorCode=5)
         else:
             return dict(success=False,
                         message="Invalid token.",
                         errorCode=3)
Exemplo n.º 5
0
 def post():
     if request.method == "POST":
         # 先鉴权
         token = request.json.get("token")
         # print(token, flush=True)
         if gen_token.authentication(token) and not pNc.if_ban(token):
             c_post = request.json.get("post")
             print(c_post, flush=True)
             # return "200"
             # if pNc.post(c_post, token, conn):
             if pNc.post(c_post, token):
                 return dict(success=True,
                             message="200 - Post successfully sent.")
             else:
                 return dict(success=False,
                             message="post error.",
                             errorCode=4)
         else:
             return dict(success=False,
                         message="Invalid token.",
                         errorCode=3)