def handlePostUpdateMember(self, post_id):
     # ENFORCE AUTHORIZATOIN (is user loggin in, or not?)
     if "userId" not in self.sessionData:
         self.handleSomeBadRequest(401)
         return
     db = PostsDB()
     post = db.getOnePost(post_id)
     # 2. if it exists? (!=None)>
     print("Here is what db.GetOnePost returned: ", post)
     if post != None:
         length = self.headers[
             "Content-Length"]  # headers is a python dictionary
         body = self.rfile.read(int(length)).decode("utf-8")
         print("the RAW body: ", body)
         # 2. parse the raw data into usable data
         parsed_body = parse_qs(body)
         if len(parsed_body) < 5:
             self.handleSomeBadRequest(400)
             return
         print("the PARSED body: ",
               parsed_body)  # parsed_body is a python dictionary
         # 3. if the data is valid, save the data into the database
         fName = parsed_body["fName"][0]
         lName = parsed_body["lName"][0]
         message = parsed_body["message"][0]
         location = parsed_body["location"][0]
         date = parsed_body["date"][0]
         # 3. delete the record from the DB
         db.updatePost(post_id, fName, lName, message, location, date)
         # 4. respond to the client (200, no body)
         self.send_response(200)
         self.end_headers()
     else:
         self.handleSomeBadRequest(404)
 def handlePostRetrieveMember(self, post_id):
     # ENFORCE AUTHORIZATOIN (is user loggin in, or not?)
     if "userId" not in self.sessionData:
         self.handleSomeBadRequest(401)
         return
     db = PostsDB()
     post = db.getOnePost(post_id)
     if post:
         self.send_response(200)
         self.send_header("Content-Type", "application/json")
         self.end_headers()
         self.wfile.write(bytes(json.dumps(post), "utf-8"))
     else:
         self.handleSomeBadRequest(404)
 def handlePostDeleteMember(self, post_id):
     # ENFORCE AUTHORIZATOIN (is user loggin in, or not?)
     if "userId" not in self.sessionData:
         self.handleSomeBadRequest(401)
         return
     # 1. query the DB: get/load the Post by id
     db = PostsDB()
     post = db.getOnePost(post_id)
     # 2. if it exists? (!=None)>
     if post != None:
         # 3. delete the record from the DB
         db.deleteOnePost(post_id)
         # 4. respond to the client (200, no body)
         self.send_response(200)
         self.end_headers()
     else:
         self.handleSomeBadRequest(404)