Python, cgi and redirect

Teemu Keskinarkaus teemu.keskinarkaus at ramk.fi
Wed May 10 06:26:47 EDT 2000


On Wed, 10 May 2000 10:20:37 GMT, nascheme at enme.ucalgary.ca (Neil
Schemenauer) wrote:

>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.
Thanks for everyone who answered. I got it working right. I put empy
'print' at the end to do extra line and now there is no more errors in
log when I'm using script!

TK



More information about the Python-list mailing list