Esempio n. 1
0
    def post(self, name):
        if StoreModel.find_by_name(name):
            return {
                'message': 'The store with name {} already exists'.format(name)
            }, 400
        store = StoreModel(name)
        try:
            store.save_to_db()
        except:
            return {'message': 'Internal server error creating store'}, 500

        return store.json(), 200
Esempio n. 2
0
    def post(self, name):
        if StoreModel.find_by_name(name):
            return {
                'message':
                "A store with name '{}' already exists.".format(name)
            }, 400
        store = StoreModel(name)

        try:
            store.save_to_db()
        except:
            {'message': 'An error occured while creating the store.'}, 500

        return store.json(), 201
 def post(self, name):
     if StoreModel.find_by_name(name):
         return {"message": "store already exists"}
     store = StoreModel(name)
     store.save_to_db()
     return store.json()