title: Download a generated file with Python
body: <p>I'm using Batik to generate a png file from a svg file using Python.</p>
  
  <p>I would like to download directly the generated file into the user's personal disk.</p>
  
  <p>Here's my Python script : </p>
  
  <pre><code>#!C:\Python27\python.exe -u
  
  import os
  import cgi
  import urllib
  print "Content-type: application/image/png\n\n" 
  print "Content-Disposition: attachment, filename=pythonchart.png\n\n"
  
  arg = cgi.FieldStorage()
  file = open('C:\wamp\www\myproj\pythonchart.svg', 'w+')
  file.write(arg['svgdata'].value)
  file.close()
  os.system('java -jar "C:\Program Files\\batik-1.7\\batik-rasterizer.jar" "C:\wamp\\www\\metrics1\\pythonchart.svg"')
  os.remove('C:\wamp\www\myproj\pythonchart.svg')
  </code></pre>
  
  <p>This results in a download dialog of this python script, I'm aware it's because of the header(content-type), but how can I add the header to that png image and download it please ?</p>