Python, cgi and redirect
Neil Schemenauer
nascheme at enme.ucalgary.ca
Wed May 10 06:20:37 EDT 2000
Teemu Keskinarkaus <teemu.keskinarkaus at ramk.fi> wrote:
>Is there simple cgi module for python that can do redirect?? Now I'm
>doing redirect in cgi-script like this:
>
>print "Status: 302 Moved"
>print "Location: http://url.to.somewhere"
>
>That works fine except I get 'Premature end of script headers' errors
>in apache error_log everytime I use that script.
You need to terminate the headers with a empty line ("\r\n"):
sys.stdout.write("Status: 302 Moved\r\n"
"Location: http://url.to.somewhere\r\n"
"\r\n")
I think most clients will accept "\n" although it is not
technically correct.
Neil
--
Every expert was once a novice.
More information about the Python-list
mailing list