I'm mimicing what jamhitz did for cgi with the "HTTP Server Application" type of project.
To the tMain object, I added three actions (Date, Author, Default) and created an "OnRequest" for each of the three actions.
To access them:
localhost:8081 -> default action
localhost:8081/Default -> default action
localhost:8081/Author -> author page
localhost:8081/Date -> date page
jamhitz - thanks for the hints and direction.
Next: create a default page with menus and / or buttons and to link those to the actions.
unit PARMain;
// localhost:8081
{$mode objfpc}{$H+}
interface
uses
SysUtils, Classes, Menus, httpdefs, fpHTTP, fpWeb, Interfaces;
type
{ TMain }
TMain = class(TFPWebModule)
MenuItem1: TMenuItem;
mAdmin: TMenuItem;
procedure AuthorRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
procedure DateRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
procedure DefaultRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
private
{ private declarations }
public
{ public declarations }
end;
var
Main: TMain;
implementation
{$R *.lfm}
{ TMain }
procedure TMain.DateRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
begin
AResponse.Content := '<h1>Date</h1><p>The current time: '
+ FormatDateTime('dd mmm yyyy hh:nn:ss',Now()) + '</p>';
Handled := true;
end;
procedure TMain.DefaultRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
begin
AResponse.ContentType := 'text/html;charset=utf-8';
AResponse.Contents.LoadFromFile('Main.html');
Handled := True;
end;
procedure TMain.AuthorRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
begin
AResponse.Contents.Add('<h1>Author</h1>');
AResponse.Contents.Add('<p>Program Authored by TeraGLEAN, LLC</p>' );
Handled := true;
end;
initialization
RegisterHTTPModule('Main', TMain);
end.