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 post(self):
     pages = open("pages.txt", "r")
     for line in pages:
         page = PageModel(line.strip("\n"))
         page.save_to_db()
     return {"message": "database updated"}