CGI Application

A CGI application (for common gateway interface, if you must know) is a process that supplements a web server. When a request arrives for a page, instead of producing the page as a copy of a file on disk, the web server can turn to a CGI application and ask it for the page; the CGI application is expected to compose the entire HTML of the page, including headers, and hand it back to the web server, which passes it on to the client that made the request.

On Macintosh, the communication between a web server and a CGI application has conventionally been performed through Apple events. In particular, an Apple event usually known (for historical reasons) as the WebSTAR event is sent by the web server to the CGI application, describing the page request. The CGI application hands back the page as the reply to this Apple event (see http://www.4d.com/products/wsdev/internetspecs.html).

This means that an applet can be used as a CGI application; and such, indeed, is the traditional Mac OS approach. If you’re using WebSTAR or some other web server that implements CGIs in this manner, you can use it directly with an applet. However, the web server that comes with Mac OS X, Apache, doesn’t work this way. Apache is a Unix web server, and Unix doesn’t have Apple events. In Unix, environment variables, along with stdin and stdout, are used as the communication medium between the server and the CGI process.

Therefore, in order to use an AppleScript applet as a CGI application with ...

Get AppleScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.