Forums

The website is only loading and does not display any results

Hello everyone! I have an website that does not display any results when I am running it and I don't know why. On my local laptop it runs perfectly and returns results in few seconds. When I run it on pythonanywhere it only keeps loading until dropping with the error "Something went wrong" and it shows the message 504-loadbalancer. I tried out the methods indicated on other posts, I even gave up at the threads that I had (since I found out the on free account you only have one single worker) but nothing worked out. I am out of ideas. This is a part of my code:

@app.route('/recommend', methods=['POST'])
def recommend():
    print('{timestamp} -- request started'.format(timestamp=datetime.utcnow().isoformat()))
    first_playlist_url = request.form.getlist('URL')[0]
    print('{timestamp} -- request started'.format(timestamp=datetime.utcnow().isoformat()))
    second_playlist_url = request.form.getlist('URL')[1]   
    most_similar_songs = find_most_similar_songs(first_playlist_url, second_playlist_url, sp)


def handle_first_playlist(first_playlist_url, sp):
    print("first url: ", first_playlist_url)
    first_playlist_uri = first_playlist_url.split('/')[-1]
    first_playlist_track_uris_names_popularity = [i for i in functions.collect_track_details(first_playlist_uri, sp)]
    print('first_playlist_track_uris_names_popularity ', first_playlist_track_uris_names_popularity)

Can someone help me? I really need some help! Best regards, Cristina

What errors do you see in your logs? (link to logs are available on the "Web" page on PythonAnywhere).

I already looked in the error log and all I can see it this:

2023-01-29 17:17:07,281: OSError: write error 2023-01-29 17:18:37,652: Couldn't read cache at: .cache 2023-01-29 17:18:37,652: User authentication requires interaction with your web browser. Once you enter your credentials and give authorization, you will be redirected to a url. Paste that url you were directed to to complete the authorization. 2023-01-29 17:18:37,762: Opened https://accounts.spotify.com/authorize?client_id=e7b4df9d41de4e898219339725eb98fd&response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1%3A9090&scope=user-library-read+playlist-modify-private in your browser

By looking at the error, I think that you're executing some code that requires interactive authentication (at Spotify). Check if they expose an API and a way to authorize programmatically.