def post(): """ This function is used to add a created post to the database. :return: Return a boolean that determines successful creation. """ log("Request - {}".format( inspect.getframeinfo(inspect.currentframe()).function)) try: # Get the info from the json file sent with the request data = request.get_json() try: title = data['postTitle'] userId = data['userId'] postText = data['postText'] topics = data['topics'] except KeyError: return invalid_json_format_string db.newPost(userId, title, postText, topics) except Exception as e: log(str(e)) return "Post successfully created!"
#time.sleep(1.5) #d.newPost(1, "Title 3", "Post 3", "Gaming,Entertainment") #time.sleep(1.5) #d.newPost(2, "Title 4", "Post 4", "Gaming") #time.sleep(1.5) #d.newPost(2, "Title 5", "Post 5", "Sports,News") #time.sleep(1.5) #d.newPost(2, "Title 6", "Post 6", "Gaming,Entertainment") #time.sleep(1.5) #d.newPost(3, "Title 7", "Post 7", "Gaming") #time.sleep(1.5) #d.newPost(3, "Title 8", "Post 8", "Sports,News") #time.sleep(1.5) #d.newPost(3, "Title 9", "Post 9", "Gaming,Entertainment") #time.sleep(1.5) d.newPost(1, "work?", "idk", "Gaming") #print(d.getAllPosts()) #print(d.getAllTopicPosts("Sports")) #print(d.getUserPosts(1)) #d.newFollow(1, 2, "Gaming") #d.newFollow(1, 3, "News") #print(d.getUserTimeline(1)) #d.newFollow(2, 3, "All") #print(d.getUserTimeline(2)) #d.unfollowUser(2, 3)