def add_artist(payload): req_data_dict = json.loads(request.data) app.logger.debug("Got request", req_data_dict) if "name" not in req_data_dict or "age" not in req_data_dict or "gender" not in req_data_dict: abort(400) name = req_data_dict["name"] age = req_data_dict["age"] gender = req_data_dict["gender"] artist = Artist(name=name, age=age, gender=gender) artist.insert() artist_single = [artist.long()] return jsonify({'success': True, 'actors': artist_single})
def add_artist(payload): req_data_dict = json.loads(request.data) app.logger.debug("Got request", req_data_dict) errno = 0 try: if "name" not in req_data_dict or "age" not in req_data_dict or \ "gender" not in req_data_dict: errno = 400 abort(errno) name = req_data_dict["name"] age = req_data_dict["age"] gender = req_data_dict["gender"] artist = Artist(name=name, age=age, gender=gender) artist.insert() artist_single = [artist.long()] return jsonify({'success': True, 'actors': artist_single}) except Exception as e: app.logger.error("add_artist:Got exception {}".format(e)) if errno == 0: abort(422) else: abort(errno)