program echo;
uses classes,sysutils,cgiapp;
Type
{ TMyCgiApplication }
TMyCgiApplication = Class(TCGIApplication)
Public
procedure DoRun; override;
end;
{ TMyCgiApplication }
procedure TMyCgiApplication.DoRun;
procedure AddRow(const aName,avalue : string);
begin
AddResponseLn(Format('
%s | %s |
',[aName,aValue]));
end;
Var
L : TStrings;
V,N : String;
I : Integer;
begin
Terminate;
EmitContentType;
AddResponseLn('');
AddResponseLn('');
AddResponseLn('Simple CGI HTML echo demo
');
AddResponseLn('Request variables
');
AddResponseLn('');
AddRow('Variable','Value');
L:=TStringList.Create;
Try
GetRequestVarList(L);
For I:=0 to L.Count-1 do
begin
L.GetNameValue(I,N,V);
AddRow(N,V);
end;
AddResponseLn('
');
AddResponseLn('CGI variables
');
AddResponseLn('');
AddRow('Variable','Value');
L.Clear;
GetCGIVarList(L);
For I:=0 to L.Count-1 do
begin
L.GetNameValue(I,N,V);
AddRow(N,V);
end;
AddResponseLn('
');
AddResponseLn('');
AddResponseLn('');
finally
L.Free;
end;
end;
begin
With TMyCgiApplication.Create(Nil) do
try
Initialize;
Run;
finally
Free
end;
end.