Use Python cgi localy on Windows7
How to setup python cgi on window 7.
Here’s my first try-out for uing python cgi on my windows7.
1- Create a fake server somewhere on your disk, like D:\myserver
2- Go to your python installation folder and find Lib (for me it’s C:\Python27\Lib). Then copy the file: CGIHTTPServer.py to the server dir you just created (e.g. D:\myserver).
3- Create a subfolder under myserver: e.g. D:\myserver\cgi-bin. This will be the folder where you put your codes in.
Copy the python code down the bottom, and save it as test.py. Then put it into D:\myserver\cgi-bin. It will display “hello world” in your browser.
4-Run the file D:\myserver\CGIHTTPServer.py 🙂 Great,You now have the server running!
5- To run your code: D:\myserver\cgi-bin\test.py. You need to put the server and port into your browser address line, like this:
print "Content-Type: text/html" print print """<html> <head><title>First Python HTTP Programming </title></head> <body> <h2>Hello World!</h2> </body> </html> """
By the way, a very nice tutorial: http://lost-theory.org/python/randomimg.html