示例#1
0
    def post(self, name):
        if StoreModel.get_item(name):
            return {
                'mesage': 'A store with {} already exists'.format(name)
            }, 400
        store = StoreModel(name)
        try:
            store.save_to_db()
        except:
            {'message': 'An errr occured while creating the store.'}, 500

        return store.json()
示例#2
0
 def get(self, name):
     store = StoreModel.get_item(name)
     if store:
         return store.json()
     return {'message': 'store not found'}, 404
示例#3
0
 def delete(self, name):
     store = StoreModel.get_item(name)
     if store:
         store.delete_from_db()
     return {'message': 'store deleted'}