* Allow to specify alternate start page

git-svn-id: trunk@37187 -
This commit is contained in:
michael 2017-09-11 18:27:07 +00:00
parent 55daab725a
commit ae8c18164d
2 changed files with 34 additions and 15 deletions

View File

@ -3,16 +3,39 @@ program webdemo;
{$mode objfpc}{$H+}
uses
fphttpapp, regreports, wmreports;
fpmimetypes,sysutils, httproute, fphttpapp, regreports, wmreports, fpwebfile;
Procedure RegisterModules(Const StartFile : String);
begin
Application.Port:=8080;
Application.AllowDefaultModule:=True;
Application.DefaultModuleName:='Page';
if IsConsole then
Writeln('Point your browser to http://localhost:',Application.Port,'/Page or http://localhost:',Application.Port);
Application.PreferModuleName:=True;
Application.Initialize;
Application.Run;
TPageReportModule.RegisterModule('Page',True);
TGenerateReportModule.RegisterModule('Generate',True);
TViewReportModule.RegisterModule('View',True);
TReportListModule.RegisterModule('ReportList',True);
if (StartFile<>'') then
RegisterFileLocation('Start',ExtractFilePath(StartFile));
HTTPRouter.RegisterRoute('/*',@ShowPage,true);
end;
begin
{$ifndef windows}
MimeTypesFile:='/etc/mime.types';
{$endif}
With Application do
begin
Port:=8080;
AllowDefaultModule:=True;
RegisterModules(GetOptionValue('s','start'));
DefaultModuleName:='Page';
if IsConsole then
begin
Writeln('Point your browser to http://localhost:',Port,'/Page or http://localhost:',Port);
if HasOption('s','start') then
Writeln('An alternate start location is available at http://localhost:',Port,'/Start/',ExtractFileName(GetOptionValue('s','start')));
end;
PreferModuleName:=True;
Initialize;
Run;
end;
end.

View File

@ -62,6 +62,8 @@ Type
Procedure HandleRequest(ARequest: TRequest; AResponse: TResponse); override;
end;
procedure ShowPage(ARequest : TRequest; AResponse : TResponse);
implementation
@ -752,11 +754,5 @@ begin
end;
initialization
TPageReportModule.RegisterModule('Page',True);
TGenerateReportModule.RegisterModule('Generate',True);
TViewReportModule.RegisterModule('View',True);
TReportListModule.RegisterModule('ReportList',True);
HTTPRouter.RegisterRoute('/*',@ShowPage,true);
end.