CGI Redirect to another page

Tom Anderson twic at urchin.earth.li
Wed Sep 24 13:17:09 EDT 2003


On Wed, 24 Sep 2003, Andrew Chalk wrote:

> In a Python script running under CGI, can I programatically redirect the
> program to another page. Assume that I have a static HTML page that I
> want displayed (e.g. index.htm). Other than 'print ...' is there any way
> to redirect to this URL (for example, like Response.Redirect() in ASP)?

you have two options:

- write a Location header; the web server will notice it and spit out the
file you specify

- write Status and Location headers, giving status 302 (or 303); the web
server will notice the Status header and give the client the appropriate
status code;  the client will then follow the redirect you give it in the
Location header

see:

http://hoohoo.ncsa.uiuc.edu/cgi/out.html
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

tom

-- 
One chants out between two worlds Fire - Walk With Me.





More information about the Python-list mailing list