[Tutor] Redirect from a CGI script
Kent Johnson
kent37 at tds.net
Thu Jan 18 14:37:36 CET 2007
Paulino wrote:
> How can i redirect to another URL from a python CGI script.
>
> Is's suposed to be as simply as:
>
> print "Location : http://newurl "
> It's not working.
>
> this simple code does't work - <redir.pyw>
> 'print "Content-Type:text/html\n\n"
Try it without the two extra newlines. A blank line in the output
signals the end of the HTTP headers and the start of the content, so the
following line is considered part of the content and is displayed by the
browser.
Kent
> 'print "Location : /cgi-bin/ecodiv.pyw "
> 'print
>
> I use CGIHTTPServer, the server script is as follows:
>
> 'from BaseHTTPServer import HTTPServer
> 'from CGIHTTPServer import CGIHTTPRequestHandler
> 'HTTPServer(("localhost", 80), CGIHTTPRequestHandler).serve_forever()
>
> instead of redirecting, it only prints 'Location : /cgi-bin/ecodiv.pyw' inthe
> browser
>
> Paulino
>
>
> ___________________________________________________________________
>
> O SAPO já está livre de vírus com a Panda Software, fique você também!
> Clique em: http://antivirus.sapo.pt
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
More information about the Tutor
mailing list