コード例 #1
0
    def post(self, name):
        # look if store is present
        store = StoreModel.find_store_by_name(name)
        if store:
            return {'message': f'store {name} already present '}, 400

        message = Store.parser.parse_args()
        new_store = StoreModel(name, message['location'])

        new_store.save_to_db()
        return new_store.get_json(), 201
コード例 #2
0
    def put(self, name):
        message = Store.parser.parse_args()
        store = StoreModel.find_store_by_name(name)

        if store:
            #update
            store.location = message['location']
        else:
            #create
            store = StoreModel(name, message['location'])

        store.save_to_db()
        return store.get_json()