FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

What is the difference between CGI and python script?

 


liangzou
There are a lot of web hosting sites supporting CGI. Is there any way to convert python scripts to CGI, so python script can be run on those web sites. I tried some python scripts on those web sites, but none of them worked.
rohan2kool
It is a common misconception that CGI is a programming language. CGI is basically a standard which allows a developer to use a standard application's output as the output sent back by a webserver as the response to a request.

For ex., if you request a page google.com, your web browser connects to google.com, and sends in an HTTP request. The server sends back a 'response'. Now, that is the standard model of a client-server transaction. Earlier, the servers were actually 'written' to cater specific requests and thereby provide dynamic response. But, what CGI does is, it allows us to use the outputs of a program as the response to a request. In this case, when you go to google.com, assuming google uses python, the server at google will ask the python interpretor to run a script [a designated script for the index page, lets say] and return whatever is the ouptut of that script.

Now, the application can be anything. It can be a .exe file, a script to be run by an interpretor [Perl/Python/Ruby/PHP].

Python is a general-purpose programming language. For example if a script on running through the python interpretor, prints 'Hello World', when run through CGI, for ex. at a point http://google.com/cgi-bin/hello.py, your browser will display the words 'Hello World'. Now, the folder 'cgi-bin' is pretty important. It's another misconception that only the scripts in the cgi-bin are executed through CGI and others are considered as standard text files. A server has some directories only the ones which allow the execution of a CGI app. For historical and conventional reasons, this folders has come to be 'cgi-bin'.

In your case mostly, you just need to place your python script in the proper folder and make sure your web server supports python.

Refer:

http://hoohoo.ncsa.uiuc.edu/cgi/intro.html
http://www.w3.org/CGI/

Tutorials and help with Python/CGI: http://webpython.codepoint.net/
expresso
thanks for the explains about CGI.... thank you very much!
Mar
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.