Bobby Roberts wrote in news:cdc29298-d005-4804-b407-81ecaf6bb1b4@
2g2000hsn.googlegroups.com in comp.lang.python:
I need to be able to offer a client "click to download" functionality
on their website. Generating the data to provide to them is not an
issue but I want them to be able to click a button and have the
response be sent to a csv file which they are prompted to download.
Can someone point me in the right direction how to do this in python.
Thanks in advance.
Assuming your using WSGI (you don't say) it would be something like this:
def wsgi( environ, start_response ):
start_response( '200 OK', [
('Content-Type','text/csv'),
('Content-Disposition', 'attachment; filename=whatever.csv')
])
...
If your using cgi it will be something like:
print "Content-Type: text/csv"
print 'Content-Disposition: attachment; filename=whatever.csv'
print
....
http://search.yahoo.com/search?p=Content-Disposition http://www.python.org/doc/2.5.2/lib/cgi-intro.html
Rob.
--
http://www.victim-prime.dsl.pipex.com/