How to open a HTML file when the python cgi program is executing?
usenet at thinkspot.net
Sat Jun 1 03:48:33 EDT 2002
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)===============
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
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
where you replace example.com with your actual domain name.
This should display an HTML page with the H1 header saying "Hello, World!!"
More information about the Python-list