program testweb;
{$mode objfpc}{$H+}
uses
Classes, SysUtils, httpdefs, custcgi,cgiapp,fphttp,fpcgi,
webutil, fpweb;
Type
TMyWeb=Class(TCustomCGIApplication)
procedure HandleRequest(ARequest: TRequest; AResponse: TResponse); override;
end;
procedure TMyWeb.HandleRequest(ARequest: TRequest; AResponse: TResponse);
Procedure AddNV(Const N,V : String);
begin
AResponse.Contents.Add('
'+N+' | '+V+' |
');
end;
Var
I,P : Integer;
N,V : String;
begin
With AResponse.Contents do
begin
BeginUpdate;
Try
Add('FPC CGI Test page');
DumpRequest(ARequest,AResponse.Contents);
Add('CGI environment:
');
Add('');
Add('Name | Value |
');
For I:=1 to GetEnvironmentVariableCount do
begin
V:=GetEnvironmentString(i);
P:=Pos('=',V);
N:=Copy(V,1,P-1);
system.Delete(V,1,P);
AddNV(N,V);
end;
Add('
');
Add('');
Finally
EndUpdate;
end;
end;
end;
Procedure Run;
begin
With TMyWeb.Create(Nil) do
try
Initialize;
Run;
Finally
Free;
end;
end;
begin
Run;
end.