title: flask make_response with large files
body: <p>So I'm real green with file I/O and memory limits and the such, and I'm having a rough time getting my web application to successfully serve large file downloads to a web browser with flask's <code>make_response</code>.  The following code works on smaller files (&lt;~1GB), but gives me a <code>MemoryError</code> Exception when I get into larger files:</p>
  
  <pre><code>raw_bytes = ""
  with open(file_path, 'rb') as r:
      for line in r:
          raw_bytes = raw_bytes + line
  response = make_response(raw_bytes)
  response.headers['Content-Type'] = "application/octet-stream"
  response.headers['Content-Disposition'] = "inline; filename=" + file_name
  return response
  </code></pre>
  
  <p>I'm assuming that sticking over 2 GB worth of binary data into a string is probably a big no-no, but I don't know an alternative to accomplishing these file download black magicks.  If someone could get me on the right track with a chunky[?] or buffered approach for file downloads, or just point me toward some intermediate-level resources to facilitate a deeper understanding of this stuff, I would greatly appreciate it. Thanks!</p>