On Tue, 3 Aug 2004, Ajay wrote:
I have the script to do the signing and pickle the signature into a file,
but how do i allow the user to download it?
Instead of pickling it to a file, pickle it to a string (using dumps).
Then you can change your script to a CGI script like the following:
#!/usr/local/bin/python <-- replace this with the real location of Python
on your server
import sys
from pickle import dumps
<do stuff>
mydata = dumps(<something>)
sys.stdout.write('Content-type: application/x-pickle\n\n')
sys.stdout.write(mydata)
That first sys.stdout.write is all that's needed to make a basic CGI
script: the Content-type line tells the web browser what type of
information to expect (the MIME type). Then you can just send whatever
data you like (this works with print statements too; but remember that
they append a \n to your data).
For normal web pages, the MIME type is text/html. The type
application/x-pickle is just something I made up, since there is no MIME
type corresponding to pickled data. You may even consider just sending
the signature as text and use the standard MIME type text/plain.
You should put your script in the cgi-bin/ directory on your web
server, and set its executable bit if it's a Unix server.