Python, cgi and redirect

Jarkko Torppa torppa at polykoira.megabaud.fi
Wed May 10 05:30:43 EDT 2000


In article <39191ca8.537672021 at news.ramk.fi>, Teemu Keskinarkaus 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.(but browser is
>redirected to url I give)  Is there something missing or is there
>ready cgi/web module to do stuff like that??

There might be module somewhere, but it is so simple that I see no
need for it.

Headerterminator (empty line) and body is missing from your cgi
script, add something like. Dunno if the body is necessary.

print
print '<html><head><title>302 go away</title></head>'
print '<body><p>go away</p></body>'

-- 
 Jarkko Torppa                torppa at staff.megabaud.fi
  Megabaud Internet-palvelut



More information about the Python-list mailing list