title: Flask send stream as response
body: <p>I'm trying to "proxy" my Flask server (i will call it Server#01) with another server(Server#02). It's working well except for one thing : when the Server#01 use send_from_directory(), i don't know how to re-send this file. </p>
  
  <p><strong>My classic "proxy"</strong></p>
  
  <pre><code>result = requests.get(my_path_to_server01)
  return Response(stream_with_context(result.iter_content()), 
                  content_type = result.headers['Content-Type'])
  </code></pre>
  
  <p>With a file a response, it's taking hours... So i tried many things. The one who work is :</p>
  
  <pre><code>result = requests.get(my_path_to_server01, stream=True)
  
  with open('img.png', 'wb') as out_file:
      shutil.copyfileobj(result.raw, out_file)
  
  return send_from_directory('./', 'img.png')
  </code></pre>
  
  <p>I would like to "redirect" my response ("result" variable), or send/copy a stream of my file. Anyways I don't want to use a physical file because it don't seems the proper way in my mind and i can imagine all problems who can happens because of that.</p>