- Irie Pascal
- Web Programming
- Company
This is a CGI version of the classic hello world program.
(********************************************************************************************
** PROGRAM : cgihello
** VERSION : 1.0.0
** DESCRIPTION : CGI version of the hello sample program.
** AUTHOR : Stuart King
** COPYRIGHT : Copyright (c) Irie Tools, 2002. All Rights Reserved.
** NOTES :
** This sample program is distributed with Irie Pascal, and is an example of how to
** write CGI programs using Irie Pascal. To make best use of this program, you should have
** a basic understanding of Pascal as well as a basic understanding of the
** Common Gateway Interface (CGI).
**********************************************************************************************)
program hello(output);
procedure WriteResponseHeader;
begin
writeln('content-type: text/html');
writeln
end;
procedure WriteHTMLHeader;
begin
writeln('<HTML>');
writeln('<HEAD>');
writeln('<TITLE>IriePascal Hello World Program</TITLE>');
writeln('</HEAD>');
end;
procedure WriteHTMLBody;
begin
writeln('<BODY>');
writeln('<BIG> Hello world!!!</BIG>');
writeln('</BODY>');
end;
procedure WriteHTMLFooter;
begin
writeln('</HTML>')
end;
begin
WriteResponseHeader;
WriteHTMLHeader;
WriteHTMLBody;
WriteHTMLFooter
end.
This program is included with Irie Pascal (in the samples directory).
The program works as follows:
WriteResponseHeader
WriteResponseHeader
writes the HTTP response header:
content-type: text/html
which tells the client (usually a web browser) that the content of the response is a 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 response file.
WriteHTMLHeader
WriteHTMLHeader writes the open html tag (marking the beginning of the html response file), and then writes a simple html header (containing just a title).
WriteBody
WriteBody
writes an html body with just a "Hello world!!!" message.
WriteHTMLFooter
WriteHTMLFooter
writes the close html tag
(marking the beginning of the html response file).
When the program ends, the web server sends all of output to the client
CGIHello has been compiled and installed on this server. Click hello.cgi.