I want to make request to url and django view should read the file and send the http response back to play the same file in browser.I got the following code but it does't play anything please anyone help me.. Right now i hard coded the file name in the code.
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()
Thank in advance..
well if you have the file you can do this
I found the answer.....