I have an image file on a server that is protected by Windows Authentication which I have to access. I used the requests_ntlm module of python to access the file with Windows Auth, which I was able to. However, on sending this data back as an image, I am getting an error.
The sample code which I am using follows:
def sendImage(imagename):
  """
  Takes image name as a parameter and get the file from the XYZ server 
  after Windows Authentication and serve the image as a response
  """
  
  username = USERNAME
  password = PASSWORD
  r = requests.get( BASE_URL + str(imagename), auth=HttpNtlmAuth(username, password))
  return send_file(
      io.BytesIO(r.content),
      mimetype='image/jpg'
  )
The traceback of error which I am getting follows:
Traceback (most recent call last):
  File "/home/pyenv/local/lib/python2.7/site-packages/werkzeug/wsgi.py", line 704, in __next__
    return self._next()
  File "/home/pyenv/local/lib/python2.7/site-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
    for item in iterable:
TypeError: 'Response' object is not iterable
I have checked that the response content with bytesIO is getting opened when I am using it with PIL, so there is so problem with the image that I am receiving.
I am unable to figure out the cause of this error.
 
    