[Tutor] Run python cgi in local Windows???

Don Arnold Don Arnold" <darnold02@sprynet.com
Sun Feb 16 01:15:02 2003


----- Original Message -----
From: prog
To: tutor-request@python.org ; tutor@python.org
Sent: Friday, February 14, 2003 8:36 PM
Subject: [Tutor] Run python cgi in local Windows???


>>I am using PythonWin and would like to make some python cgi's.
>>is there a possibility that a cgi can run on a local Windows which
>>is NOT a web server?
>>
>>For example, when you type:
>>
>>c:/python/mycounter.cgi
>>
>>in the address box of the IE, the IE triggers the python or whatever
>>machnism and executes the cgi and display the 'print ...' to back to
>>the browser?

>>Thx in advance.
>>Pan

Actually, Python comes with a mini-webserver in the CGIHttpServer module.
 Here's how you can set it up from the command prompt:

1. Create a home directory for your server.

    md \myserver

2. Make a cgi-bin subdirectory off the home directory.

    cd \myserver
    md cgi-bin

3. Copy the file CGIHttpServer.py to the home directory.

    cd \myserver
    copy \python22\Lib\CGIHttpServer.py

4. Put your cgi scripts in the cgi-bin directory.

5. Change to the home directory and run CGIHttpServer.py

Pointing your browser at http://localhost:8000/cgi-bin/somescript.py will
now execute the cgi script somescript.py.
This is a relatively simple server, and I believe it doesn't handle the POST
request.
If you need that functionality, you might want to go to www.imatix.com and
download their xitami web server.
It's fast, easy to install, and runs Python cgi scripts quite nicely.

HTH,
Don