def post_artists(jwt): body = request.get_json() if (body is None): abort(422) name = body.get('name') portfolio_link = body.get('portfolio_link') if (name is None or portfolio_link is None): abort(422) artist = Artist(name=name, portfolio_link=portfolio_link) try: artist.insert() except Exception: abort(422) return jsonify({'success': True, 'artist': artist.format()})
def post_artist(jwt): data = request.get_json() name = data.get('name', None) artist = Artist(name=name) if name is None: abort(400) try: artist.insert() return jsonify({ 'success': True, 'artist': artist.format() }), 201 except Exception: abort(500)
def create_artist(*args, **kwargs): """Creates a Artist. Returns: response: json, status_code """ try: body = request.get_json() artist = Artist(name=body.get('name'), phone_number=body.get('phone_number'), email=body.get('email'), event=body.get('event'), website=body.get('website'), instagram_link=body.get('instagram_link'), image_link=body.get('image_link')) artist.insert() return jsonify({"success": True, "artists": artist.format()}), 201 except Exception as e: app.logger.error(e) abort(422)
def create_artist(): body = request.json artist_name = body['name'] artist_age = body['age'] artist_style = body['style'] try: new_artist = Artist( name=artist_name, age=artist_age, style=artist_style) print('Post initialized') new_artist.insert() except Exception as e: print(e) print("something went wrong") print(e.args) abort(400) return jsonify({ "success": True, "artists": new_artist.format() }), 200