def post(self, name): if StoreModel.find(name): return {"message": "Store '{}' already exists".format(name)}, 400 store = StoreModel(name) try: store.save() except: return { "message": "An error occurred while creating the store" }, 500 return store.json(), 200
def delete(self, name): store = StoreModel.find(name) if store: store.delete() return {"message": "Store deleted"}
def get(self, name): store = StoreModel.find(name) if store: return store.json() return {"message": "Store not found"}, 404