Beispiel #1
0
 def put(self):
     # update a single blogpost
     print('Blogpost API: update a single blogpost')
     requestData = request.get_data().decode('utf8')
     blogpostData = json.loads(requestData)        
     newBlogpost = Blogpost()
     newBlogpost.id = blogpostData['p_customer_id']
     newBlogpost.postDate = blogpostData['p_post_date']
     newBlogpost.title = blogpostData['p_title']
     newBlogpost.postContent = blogpostData['p_post_content']
     newBlogpost.keywords = blogpostData['p_keywords']
     newBlogpost.createDate = blogpostData['p_create_date']
     mod_blogpost(newBlogpost) 
     return jsonify({"data":"5"})
Beispiel #2
0
 def post(self):
     # create a new blogpost
     print('Blogpost API: create a new blogpost')
     # print(type(json.dumps(request.data)))
     print('1')
     requestData = request.get_data().decode('utf8')
     print('2')
     blogpostData = json.loads(requestData)
     print('3')
     newBlogpost = Blogpost()
     print('4')
     newBlogpost.postDate = blogpostData['p_post_date']
     print('5')
     newBlogpost.title = blogpostData['p_title']
     print('6')
     newBlogpost.postContent = blogpostData['p_post_content']
     print('7')
     newBlogpost.keywords = blogpostData['p_keywords']
     print('8')
     newBlogpost.createDate = blogpostData['p_create_date']
     print('9')
     add_blogpost(newBlogpost)
     # TODO: Finish this section, then do "def put()"
     return jsonify({"Saved": True})