Hello I am trying to make a django website using the spotify api, so I am trying to get some simple example code working using the spotipy python library, but keep getting a http post 500 whenever my spotipy code is called.
Right now if you click a button on the website it makes a post request to one of my endpoints, which calls a python function and is supposed to return text. This is the code in the python function:
import spotipy
def spotifyleastplayed_py(request):
print("spotifyleastplayed_py()")
if request.method == 'POST':
print("0")
sp = spotipy.Spotify()
print("1")
results = sp.search(q='weezer', limit=20)
print("2")
print(results)
data = "temp spotifyleastplayed_py() Return Data"
return HttpResponse(data) #HttpResponse(json.dumps("{test:bobo}"))
When the function is called, my console outputs the following error message:
[06/Oct/2019 21:49:03] "GET /spotifyleastplayed HTTP/1.1" 200 1992
spotifyleastplayed_py()
0
1
[06/Oct/2019 21:49:07] "POST /spotifyleastplayed_py/ HTTP/1.1" 500 6326
Do I need to add the spotipy url to django somewhere so the library can make calls successfully? It seems like its failing to make the http request to spotipy.