def post(self, name): store = StoreModel.find_name(name) #print('item',item) if store: return { 'message': "the store '{}' already exists".format(name) }, 400 store = StoreModel(name) try: store.save_to_db() except: return { 'message': 'An error occured while creating the store' }, 500 return store.json(), 201
def delete(self, name): store = StoreModel.find_name(name) if store: store.delete_from_db() return {'message': 'store deleted'}
def get(self, name): store = StoreModel.find_name(name) if store: return store.json() return {'message': 'store not found'}, 404