4.1 What is CGI?

CGI stands for Common Gateway Interface and is a simple specification which defines some common variables and allows computer programs to run on web servers.

CGI scripts are simply computer programs which run on a web server and output HTTP headers and HTML in a standard format back to the web browser. CGI scripts can be written in virtually any language including Python. CGI scripts can be used for creating dynamic web pages, responding to user actions, accessing databases, creating shopping carts, etc.

CGI programs have to have special permission to run on a server. This is to prevent people uploading files to a server and then running potentially harmful programs. Many ISP's do not let people run CGI scripts on their web space so you will have to find a server that does or use the webserver provided with PythonWeb (described in the previous section).

Rather than printing to the screen, CGI programs print to the web browser so that a standard print command produces text which will be seen on a web browser.