Пример #1
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:
            return {"message": "An error occurred creating the store."}, 500

        return store.json(), 201
Пример #2
0
    def post(self, name):
        if StoreModel.find_by_name(name):
            return {"message": "Store already exists"}, 409

        store = StoreModel(name)
        try:
            store.save()
        except:
            return {"message: An error occurered while creating the store."
                    }, 500

        return store.json(), 201