<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Still doesn't work. <br>
<br>
This should be a server issue, once I use a very basic server:<br>
<pre wrap="">'from BaseHTTPServer import HTTPServer 
'from CGIHTTPServer import CGIHTTPRequestHandler
'HTTPServer(("localhost", 80),CGIHTTPRequestHandler).serve_forever()</pre>
I tryed also with the Karrigel embeded server and nothing happened...<br>
<br>
I tryed all the sugestions from Andre with no succes.<br>
<br>
The cgi script as only these two lines:<br>
'print "Content-type:&nbsp;&nbsp;&nbsp; text/html\r\n"<br>
'print "Location:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a class="moz-txt-link-freetext" href="http://python.org/\r\n\r">http://python.org/\r\n\r</a>"<br>
<br>
I have a Win Xp pro machine with Python2.5.<br>
<br>
Paulino<br>
<blockquote cite="mid1169262778.17376.103.camel@www.venix.com"
 type="cite">
  <pre wrap="">On Sat, 2007-01-20 at 02:10 +0000, Paulino wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Thank you Andre,

well it doesn't work either!
    </pre>
  </blockquote>
  <pre wrap=""><!---->
This works, 

#!/usr/bin/python
print "Location:        <a class="moz-txt-link-freetext" href="http://python.org/\r\n\r">http://python.org/\r\n\r</a>"

as does this

#!/usr/bin/python
print "Content-type:    text/html\r"
print "Location:        <a class="moz-txt-link-freetext" href="http://python.org/\r\n\r">http://python.org/\r\n\r</a>"


Tested using Apache on Linux.  A redirect should have a 3xx status.
Apache saw the location header and fixed the status to be 302.  My
browser (firefox) received the 302 status with the new location and
requested the new URL.

Each header line should be separated by \r\n.  A Python print on linux
will only output \n.  In actual practice, that appears to work OK.
either the browsers tolerate the missing \r or Apache fixes the data
stream.

Firefox plugins called tamperdata and liveheaders can be very helpful
for debugging these kinds of interactions.

Get the redirect to a real web site working.  Then fix it to redirect to
your script.  Use tamperdata to see what is going on if you have trouble
making it work.

  </pre>
  <blockquote type="cite">
    <pre wrap="">Paulino
    </pre>
    <blockquote type="cite">
      <pre wrap="">Andre Engels escreveu:
2007/1/18, Paulino <a class="moz-txt-link-rfc2396E" href="mailto:paulino1_at_sapo.pt@.syntax-error">&lt;paulino1_at_sapo.pt@.syntax-error&gt;</a>: 
        How can i redirect to another URL from a python CGI script.
        
        Is's suposed to be as simply as:
        
        print "Location : <a class="moz-txt-link-freetext" href="http://newurl">http://newurl</a> "
        It's not working.
        
        this simple code does't work - &lt; redir.pyw&gt;
        'print "Content-Type:text/html\n\n"
        '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


I haven't tested it, but I think I had a similar error recently, and
that was solved by removing the \n\n at the end of the Content-Type
line. You could try that.






-- 
Andre Engels, <a class="moz-txt-link-abbreviated" href="mailto:andreengels@gmail.com">andreengels@gmail.com</a>
ICQ: 6260644  --  Skype: a_engels
      </pre>
    </blockquote>
    <pre wrap="">_______________________________________________
Tutor maillist  -  <a class="moz-txt-link-abbreviated" href="mailto:Tutor@python.org">Tutor@python.org</a>
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a>
    </pre>
  </blockquote>
</blockquote>
<br>
</body>
</html>