【发布时间】:2020-02-04 06:34:59
【问题描述】:
您好,我正在尝试使用 spotify api 制作一个 django 网站,因此我正在尝试使用 spotipy python 库获取一些简单的示例代码,但每当调用我的 spotipy 代码时,都会收到 http post 500。
现在,如果您单击网站上的按钮,它会向我的一个端点发出发布请求,该端点调用 python 函数并应该返回文本。这是python函数中的代码:
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}"))
函数调用时,我的控制台输出如下错误信息:
[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
我是否需要将 spotipy url 添加到 django 某个地方以便库可以成功调用?似乎它未能向 spotipy 发出 http 请求。
【问题讨论】:
标签: python django http spotify spotipy