Exemple #1
0
 def post(self):
     request_data = AddPage.parser.parse_args()
     if PageModel.find_by_url(request_data['url']):
         return {"message": "Page already exists in database"}, 400
     page = PageModel(request_data['url'])
     try:
         page.save_to_db()
     except:
         return {"message": "An error occured"}, 500
     return {"message": "page added"}
Exemple #2
0
 def delete(self):
     request_data = AddPage.parser.parse_args()
     page = PageModel.find_by_url(request_data['url'])
     if page:
         page.delete_from_db()
         return {
             "message":
             "page {} deleted from db".format(request_data['url'])
         }
     return {
         "message":
         "error - page {} doesnt exist in db".format(request_data['url'])
     }