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

Ken ken at hotmail.com
Sat Jun 1 04:18:50 EDT 2002


"Sheila King" <usenet at thinkspot.net> wrote in message
news:ad95l1.i0.1 at kserver.org...
> On Sat, 1 Jun 2002 16:43:01 +1000, "Ken" <ken at hotmail.com> wrote in
> comp.lang.python in article <ad9q91$vlrsb$1 at ID-49758.news.dfncis.de>:
>
> > How do I open a HTML file when the cgi program is executing?
> >
> > The only method I can think of, which doesn't work is this:
> > <meta HTTP-EQUIV="REFRESH" CONTENT="0; URL=main.html">
>
> What do you mean by "open an HTML file when the cgi program is executing"?
>
> Are you talking about displaying the resulting HTML output.
>
> HTML output from a cgi script is simply printed to standard output.
>
> Here is a very simply cgi script (basically "Hello World"):
>
> =============(begin hello script)===============
> #!/usr/bin/env python
>
> print "Content-type: text/html\n"
> print "<HTML><HEAD><TITLE>Hello, World!</TITLE></HEAD>"
> print "<BODY><H1>HELLO, WORLD!!!</H1></BODY></HTML>"
>
> =============(end hello script)===============
>
> Change the interpreter path
>
> #!/usr/bin/env python
>
> as appropriate for your server.
>
> Save the above as something like hello.py or hello.cgi
> upload it to the cgi-bin on your server. Make sure file permissions are
set
> for executable (this will probably be 777 or 755 depending on your server
> configuation). Make sure you upload it in ASCII/TEXT mode.
>
> Then point your browser to
>
> http://www.example.com/cgi-bin/hello.py
>
> where you replace example.com with your actual domain name.
>
> This should display an HTML page with the H1 header saying "Hello,
World!!"
>
> --
> Sheila King
> http://www.thinkspot.net/sheila/
> http://www.k12groups.org/
>

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.

Can anyone help?

Thanks





More information about the Python-list mailing list