CGIHello.pas
The following example CGI program is included with Irie Pascal (look in the samples
directory). A brief description, of how this program works, follows the program listing
below.
program hello(output);
procedure WriteResponseHeader;
begin
writeln('content-type: text/html');
writeln
end;
begin
WriteResponseHeader;
writeln('<HTML>');
writeln('<HEAD>');
writeln('<TITLE>IriePascal Hello World Program</TITLE>');
writeln('</HEAD>');
writeln('<BODY>');
writeln('<BIG> Hello world!!! </BIG>');
writeln('</BODY>');
writeln('</HTML>')
end.
|
This is a CGI version of the classic hello world program.
As you can see, the first thing this program does, is call the WriteResponseHeader
procedure (which as its name suggests writes the HTTP response header). In this case the
Response header consists of the line
content-type: text/html
which tells the client (usually a web browser) that the content of the response is a
text file, and further that this text file is an html text file. Notice that the built-in
procedure writeln is used to write the response header to the standard
output stream, and on to the waiting web server. Notice also the second writeln,
which is used to write a blank line after the response header. The blank line tells the
web server that the response header is finished, and that what follows, is the content of
the response (in this case, an html file containing the Hello World!!! message).
The program then writes the rest of the response and exits.
The web server sends all of this to the client (after completing the response headers).
This application has been compiled and installed on this server. To see it run, click here.
Next > CGIInfo |