Tcl scripts as CGI application
The Common Gateway Interface (CGI) is the standardized way the CGI-compliant web server can use external application to do some tasks, and essentially to generate the HTML output to the client. We do not intend to describe CGI itself—as it is beyond the scope of this book, but to focus how Tcl can be arranged here. The full specification of CGI, is described in detail in RFC 3875 (http://www.ietf.org/rfc/rfc3875.txt).
The CGI standard defines that the application may be written in any language. The communication between the server and the application is as follows:
The input for the application is provided in terms of environmental variables (see CGI manual for detailed list of these variables). In the case of HTTP POST request, the content of that request is available as standard input.
The application writes the resulting document to standard output. This output must contain at least the HTTP header defining the MIME type of the document, and the content.
To...