def results(): last_evaluated_key = request.args.get("last_evaluated_key", None, type=str) prev_evaluated_key = request.args.get("prev_evaluated_key", None, type=str) entity_type = request.args["entity_type"] term = request.args["term"] if entity_type == "artist": albums = Artist.find_by_name(term) # print(dir(albums)) return render_template("artist-results.html", albums=albums, term=term) elif entity_type == "album": albums, last_evaluated_key, prev_evaluated_key = Album.find_by_title( term, prev_evaluated_key, last_evaluated_key, PAGE_SIZE) return render_template( "results.html", albums=albums, term=term, entity_type=entity_type, last_evaluated_key=last_evaluated_key, prev_evaluated_key=prev_evaluated_key, ) elif entity_type == "track": albums = Album.find_by_track(term) return render_template("results.html", albums=albums, term=term, entity_type=entity_type)
def results(): last_evaluated_key = request.args.get('last_evaluated_key', None, type=str) prev_evaluated_key = request.args.get('prev_evaluated_key', None, type=str) entity_type = request.args['entity_type'] term = request.args['term'] if entity_type == 'artist': artists = Artist.find_by_name(term) return render_template('artist-results.html', artists=artists, term=term) elif entity_type == 'album': albums, last_evaluated_key, prev_evaluated_key = Album.find_by_title( term, prev_evaluated_key, last_evaluated_key, PAGE_SIZE) return render_template('results.html', albums=albums, term=term, entity_type=entity_type, last_evaluated_key=last_evaluated_key, prev_evaluated_key=prev_evaluated_key) elif entity_type == 'track': albums = Album.find_by_track(term) return render_template('results.html', albums=albums, term=term, entity_type=entity_type)
def artist_by_name(name): albums = Artist.find_by_name(name) return render_template("artist.html", albums=albums, artist_name=name)