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

Jiri Baum jiri at baum.com.au
Sat Jun 1 06:12:25 EDT 2002


Ken:
> No, I mean at some point in the script, I want to get out of it and use
> ordinary HTML instead (main.html in this example). I don't mean the
> "print" command.

If you realize this before you've output anything, you can use one of the
redirection / refresh headers, such as "Location".

print """Content-type: text/html
Location: http://replacement-url

<p><a href="http://replacement-url">Click here</a></p>
"""

Theoretically it should be sufficient to just give the Location, but put in
a human-readable redirection just in case.

Otherwise, if you've already started, you must continue. Just open the file
and print it.


As for frames, there's the main document, which decides which frames get
shown; and then the server gets separate requests for each of the frames.
You might want to browse a few pages with telnet to get a feel for how
things work.

Jiri
-- 
Jiri Baum <jiri at baum.com.au>           http://www.csse.monash.edu.au/~jirib
  MAT LinuxPLC project --- http://mat.sf.net --- Machine Automation Tools



More information about the Python-list mailing list