delphimvcframework/samples/serversideviews_templatepro/ServerSideViewsTemplatePro.dpr

63 lines
1.5 KiB
ObjectPascal
Raw Normal View History

2024-08-12 10:38:16 +02:00
program ServerSideViewsTemplatePro;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
MVCFramework,
MVCFramework.Signal,
MVCFramework.Logger,
{$IFDEF MSWINDOWS}
Winapi.ShellAPI,
Winapi.Windows,
{$ENDIF }
IdHTTPWebBrokerBridge,
2024-08-18 11:40:14 +02:00
TemplatePro,
2024-08-24 16:32:38 +02:00
MVCFramework.Commons,
2024-08-12 10:38:16 +02:00
MVCFramework.View.Renderers.TemplatePro,
Web.WebReq,
Web.WebBroker,
WebModuleU in 'WebModuleU.pas' {WebModule1: TWebModule},
WebSiteControllerU in 'WebSiteControllerU.pas',
DAL in 'DAL.pas',
MyDataModuleU in '..\renders\MyDataModuleU.pas' {MyDataModule: TDataModule},
2024-08-18 11:40:14 +02:00
CustomTemplateProFiltersU in 'CustomTemplateProFiltersU.pas';
2024-08-12 10:38:16 +02:00
{$R *.res}
procedure RunServer(APort: Integer);
var
LServer: TIdHTTPWebBrokerBridge;
begin
ReportMemoryLeaksOnShutdown := True;
LogI(Format('Starting HTTP Server on port %d', [APort]));
LServer := TIdHTTPWebBrokerBridge.Create(nil);
try
LServer.DefaultPort := APort;
LServer.Active := True;
{$IFDEF MSWINDOWS}
2024-08-18 11:40:14 +02:00
ShellExecute(0, 'open', PChar('http://localhost:' + inttostr(APort)), nil, nil, SW_SHOW);
2024-08-12 10:38:16 +02:00
{$ENDIF}
LogI('Ctrl+C to stop the server');
2024-08-12 10:38:16 +02:00
WaitForTerminationSignal;
EnterInShutdownState;
LServer.Active := False;
finally
LServer.Free;
end;
end;
begin
ReportMemoryLeaksOnShutdown := True;
try
if WebRequestHandler <> nil then
WebRequestHandler.WebModuleClass := WebModuleClass;
2024-08-24 16:32:38 +02:00
TemplateProContextConfigure;
2024-08-12 10:38:16 +02:00
RunServer(8080);
except
on E: Exception do
LogE(E.ClassName + ': ' + E.Message);
end;
end.