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
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 create_model(): if request.method == "POST": name = request.form['name'] if StoreModel.find_by_name(name): return "Model already exists with name. Try another name" store = StoreModel(name=name, username=session['username']) try: store.save_to_db() except: return "Error creating model" return redirect(url_for(".index")) return render_template("models/new_model.html")
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()