CGI: Run Script then load page

Gerhard Häring gerhard.nospam at bigfoot.de
Sun Aug 5 06:34:55 EDT 2001


On 4 Aug 2001 21:41:11 -0700, Lang <bob at tharin.com> wrote:
>Any cgi/web person out there,
>
>I wrote a couple cgi scripts that I use to manage a database.  When I
>send changes through a form, it calls a script that makes the database
>commit.  Once it is done with the commit, it prints out a return
>button (that's all that shows up on the page) which needs to be pushed
>to return to the main page.  How do I call the script, run the commit,
>and then return to a given URL as one step instead of two?

The solution Roman proposed works, but the following is technically better :-)
It uses features of the HTTP protocol instead.

#!/usr/bin/env python
print "Status-Code: 301"                        # Moved permanently
print "Location: http://www.rfceditor.org/"     # New location
print ""                                        # Newline ends HTTP header

>I think that this is pretty basic, but I can't find an answer. 

This and more useful information can be found in RFC 2616 (HTTP 1.1).
http://www.rfceditor.org feature a searchable RFC index, for example.

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://highqualdev.com              public key at homepage
public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y: x+y, [chr(ord(x)^42) for x in list('zS^BED\nX_FOY\x0b')])



More information about the Python-list mailing list