How to exit a cgi file after a download

Benjamin Kaplan benjamin.kaplan at case.edu
Wed Sep 4 16:51:00 EDT 2013


On Sep 4, 2013 1:29 PM, "Ferrous Cranus" <nikos at superhost.gr> wrote:
>
> Python help.
>
> I use the following code in a cgi file
> to give the client a download link to
> download a file.
>
> ---
>
> print "%s" % ('<a href = "Setup.zip"> Down
> Load </a>')
>
> ----
>
> A click on "Down Load" opens a pop up browser
> window which allows the user to choose where
> to download the "Setup.zip" file, then after
> the download, the pop up window closes.
>
> My problem is that I want the cgi form, which
> contains the link, to also close after the
> download.  The only way I can figure out to
> close the cgi window is to give the user a
> button to close it.
>
> Without closing it, the client can download
> again and forever if they choose to because
> the cgi window is open and the link is still
> active.
>
> I am trying to find a way to close the cgi
> file or call another file after the download
> without adding a close button and asking the
> client to close the window.
>
> jd
>
>

There is no such thing as a "cgi form" or "cgi window". Your cgi script
runs when the user requests a Web page, generates a page, and then ends. At
that point, python has stopped running. If your want the client's browser
window to close, that's not a python problem. If you want to invalidate the
download link after one successful download, you'll have to add a unique
identifier to the url and keep track of which identifiers are still valid.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130904/a45ed34d/attachment.html>


More information about the Python-list mailing list