Mit omtalte testprogram forvirer dig sikkert bare da det er en overbygning med nogle funktioner hentet fra
www.cgieksperten.com, men du får det alligevel da du kan se opbygningen.God fornøjelse.
//This is an example how to do a console CGI application with CGI Expert.
// 1) Add a DEFINE variable named "CONSOLE_MODE" in your project.
// The "CONSOLE_MODE" DEFINE is set in Delphi menu:
// "Project - Project Options - Directories/Conditionals - Conditional Defines"
// 2) Create your application in the Project source file.
// 3) Add the line "{$APPTYPE CONSOLE}" in the Project source file.
// Note! If compilation would fail try do "Build all"
// If having the full source version of CGI Expert, the size of a
// normal Console application will be reduced to about 100KB.
// With non source version of CGI Expert, the size of a console application
// will not be reduced.
program ConsoleCGI;
{$APPTYPE CONSOLE}
uses
CGISEng, // Add support for Standard CGI interface
CGIWEng, // Add support for Win CGI interface
HttpEng, // This package contains the basic CGI Expert routines
SysUtils; // System utilities needed by most applications
procedure FilterFile(EntryName : String; var Handled : Boolean);
begin
with CurrentHttpEngine do
begin
if EntryName='Text' then
PutLine('FIKON')
else
Handled:=False;
end;
end;
var
I : Integer;
begin
with CurrentHttpEngine do
try
//All Customization of THttpEngine properties must be done before
//the call of the StartDocument procedure.
AllowedMethods.Get:=True; //Default
AllowedMethods.Post:=True; //Default
AllowedMethods.Put:=True; //Not Default
//A call to the StartDocument procedure must be done before accessing
//form variables or generating any output.
StartDocument;
//Now you can produce your html code
PutLine('<html><body><h2>Console application with CGI Expert</h2>');
PutLine('Form variables passed to this CGI:<br>');
for I:=0 to FormVariables.Count-1 do
PutLine(FormVariables.Strings[i]+'<br>');
PutLine('<p>Server variables passed to this CGI:<br>');
for I:=0 to ServerVariables.Count-1 do
PutLine(ServerVariables.Strings[i]+'<br>');
PutLine('</body></html>');
except
On E: Exception do
UnHandledException(E); //Report any Exception to logfile and Browser window
// Log(E.Message); //Report any Exception only to logfile
end;
end.