25

The problem is I am unable to send headers when using send_file, is there any workaround for this?

I want to be able to send headers when sending files to client.

return send_file(mp3_filepath, 'audio/mpeg')
Alireza
  • 6,497
  • 13
  • 59
  • 132

1 Answers1

52
from flask import make_response, send_file    

response = make_response(send_file(mp3_filepath))
response.headers['X-Something'] = 'header value goes here'
return response
Community
  • 1
  • 1
0x90
  • 6,079
  • 2
  • 36
  • 55