mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-06 19:10:18 +02:00
* Allow to specify alternate start page
git-svn-id: trunk@37187 -
This commit is contained in:
parent
55daab725a
commit
ae8c18164d
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user