How to open a HTML file when the python cgi program is executing?

Ian Bicking ianb at colorstudy.com
Sat Jun 1 17:25:13 EDT 2002


On Sat, 2002-06-01 at 15:51, Sheila King wrote:
> On 01 Jun 2002 16:12:02 -0400, Kragen Sitaker <kragen at pobox.com> wrote in
> comp.lang.python in article <83n0uevjvx.fsf at panacea.canonical.org>:
> 
> > Sheila King <usenet at thinkspot.net> writes:
> > > print "Location: http://replacement-url\n"
> > > 
> > > You should have nothing before this, and there's no point in having
> > > anything after it, since the page is being redirected.
> > 
> > Some browsers (in particular old versions of Opera) have problems with
> > redirects every once in a while; that's why redirects traditionally
> > contain HTML, in case the browser is broken.
> 
> I posted a short, quick, quip of a reply to your message. Although I've
> cancelled it now, it will probably still show up on most news servers.
> 
> In any case, a Google Groups search does find support for your statements
> (which I'm sure is no surprise to you).
> 
> As an example:
> http://groups.google.com/groups?as_umsgid=DoBG3t.LMv%40world.std.com

Well, that's HTTP -- apache CGI has a few more details.  If you don't
include a body, Apache will create one for you (using it's standard
mechanisms and text).

*However* you should send a Status header as well, because if you don't
*and* you don't give a fully qualified URL (i.e., with http://), then
Apache will do a local redirect.  In the case of a local redirect, the
browser will not be aware of the redirect, but the output will be
replaced with the target location.  Relative links in the target HTML
might be broken because of this.

  Ian







More information about the Python-list mailing list