コード例 #1
0
ファイル: store.py プロジェクト: Pravesh45/RestAPI
 def post(self, name):
     ans = StoreModel.get_store_byname(name)
     if ans:
         return {
             'message': 'Store with the name {} already exists'.format(name)
         }, 400
     store = StoreModel(name)
     try:
         store.save_to_db()
     except:
         return {'message': 'There was a problem posting the store'}, 500
     return store.json(), 201
コード例 #2
0
ファイル: store.py プロジェクト: Pravesh45/RestAPI
 def get(self, name):
     store = StoreModel.get_store_byname(name)
     if store:
         return store.json()
     return {'message': 'Store does not exists'}, 404
コード例 #3
0
ファイル: store.py プロジェクト: Pravesh45/RestAPI
 def delete(self, name):
     store = StoreModel.get_store_byname(name)
     if store is None:
         return {'message': 'store does not exists'}
     store.del_from_db()
     return {'message': 'store succesfully deleted'}