コード例 #1
0
 def delete(self, name):
     store = StoreModel.findStoreByName(name)
     if store:
         try:
             store.delete_from_db()
             return {"message": name + " store has been deleted"}
         except:
             return {
                 "message": "an error was occured while deleting the store"
             }, 500
     return {"message": "The requested store was not found"}, 400
コード例 #2
0
 def post(self, name):
     if StoreModel.findStoreByName(name):
         return {"message": name + " has already existed"}, 400
     store = StoreModel(name)
     try:
         store.save_to_db()
     except:
         return {
             "message": "an error was occured while creating the store"
         }, 500
     return store.json()
コード例 #3
0
 def get(self, name):
     store = StoreModel.findStoreByName(name)
     if store:
         return store.json()
     return {"message": name + " was not found"}, 404