0
我想向url和django视图发出请求,应该读取该文件并发回http响应,以便在browser.I中播放相同的文件。但它不会播放任何东西,请任何人帮助我.. 现在我硬编码的代码中的文件名。如何在django(python)中通过http响应播放音频文件
url: http://localhost/playfile/audiofile_name
def playAudioFile(request):
try:
fname="C:\\test\\audio\\t.mp3"
wrapper = FileWrapper(file(fname))
print content_type
response = HttpResponse(wrapper, content_type="audio/mpeg")
print response
response['Content-Length'] =os.path.getsize(fname)
return response
except:
return HttpResponse()
预先感谢..
你确定django中有一个'Sound'类,它的行为与问题作者期望的一样? – Alexey 2013-05-10 09:11:16