summaryrefslogtreecommitdiff
path: root/packages/fcl-base/examples/testcgi.pp
diff options
context:
space:
mode:
Diffstat (limited to 'packages/fcl-base/examples/testcgi.pp')
-rw-r--r--packages/fcl-base/examples/testcgi.pp61
1 files changed, 61 insertions, 0 deletions
diff --git a/packages/fcl-base/examples/testcgi.pp b/packages/fcl-base/examples/testcgi.pp
new file mode 100644
index 0000000000..24a1e35f87
--- /dev/null
+++ b/packages/fcl-base/examples/testcgi.pp
@@ -0,0 +1,61 @@
+{$mode objfpc}
+{$H+}
+
+program testcgi;
+
+uses cgiapp,classes,sysutils;
+
+Type
+ TTestCGI = Class(TCGIApplication)
+ Procedure DoRun; override;
+ end;
+
+Procedure TTestCGI.DoRun;
+
+Var
+ L : TStrings;
+ I: Integer;
+
+begin
+ ContentType:='text/html';
+ EmitContentType;
+ L:=TStringList.Create;
+ Writeln('<HTML><TITLE>',title,'</TITLE><BODY>');
+ Try
+ Writeln('<H1>List of CGI variables:</H1>');
+ GetCGIVarList(L);
+ For I:=0 to L.Count-1 do
+ Writeln(L[i],'<BR/>');
+ Writeln('<H1>List of environment variables:</H1>');
+ GetEnvironmentList(L);
+ For I:=0 to L.Count-1 do
+ Writeln(L[i],'<BR/>');
+ If (RequestVariableCount>0) then
+ begin
+ Writeln('<H1>List of form variables:</H1>');
+ GetRequestVarList(L);
+ For I:=0 to L.Count-1 do
+ Writeln(L[i],'<BR/>');
+ Writeln('<H1>List of form variables, tabular format:</H1>');
+ Writeln('<table width="100%" border="1">');
+ Writeln('<TR><TH>Name</TH><TH>Value</TH></TR>');
+ GetRequestVarList(L,True);
+ For I:=0 to L.Count-1 do
+ Writeln('<TR><TD>',L[i],'</TD><TD>',RequestVariables[L[i]],'</TD></TR>');
+ end;
+ Finally
+ Writeln('</BODY></HTML>');
+ Terminate;
+ end;
+end;
+
+begin
+ With TTestCGI.Create(Nil) do
+ Try
+ Title:='Test CGI application';
+ Initialize;
+ Run;
+ Finally
+ Free;
+ end;
+end.