def post_album(jwt): # Process request data data = request.get_json() title = data.get('title', None) year = data.get('year', None) artist = data.get('artist', None) # return 400 for empty title or year or artist if title is None or year is None or artist is None: abort(400) try: album = Album(title=title, year=year, artist=artist) album.insert() return jsonify({ 'success': True, 'album': album.format() }), 201 except Exception: abort(500)