The Server and CGI

Hopefully, you have access to some sort of web server. When people talk about a “web server,” they are generally referring to two things: a program that accepts a request for resources (HTML pages, images, applets, DOM objects, etc.) and returns resources, as well as the actual collection of resources to return (and, I guess, the computer where everything lives, if you want to get picky). When we talk about a web server here, we refer only to the program that does the serving; we assume that there is also a corresponding collection of web pages and images to be served.

The requests made to and responses returned by the web server must be in the standard form described by the HyperText Transfer Protocol (HTTP). Web servers are an inherently simple concept that in practice may be very simple programs or very complicated affairs. The popular Apache web server falls somewhere in between. Apache takes a modular design approach; it has a very fast, simple core set of operations that may be extended with other modules. Whichever web server you run, the basic capabilities of handling requests and returning resources are the primary function of the server.

When a web browser requests an image from a server, the request is in the form of a URL, just like any other HTTP request. This URL points to a file that resides on the same computer as the web server, in its collection of resources. Generally the web server points to a specific root directory, which it uses to determine ...

Get Perl Graphics Programming 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.