delphimvcframework/samples/angular/dmvcframeworkserver/Angular2SampleServer.dpr

58 lines
1.7 KiB
ObjectPascal
Raw Normal View History

2016-12-01 15:23:03 +01:00
program Angular2SampleServer;
{$APPTYPE CONSOLE}
2016-12-01 15:23:03 +01:00
uses
System.SysUtils,
Winapi.Windows,
Winapi.ShellAPI,
Web.WebReq,
Web.WebBroker,
MVCFramework.Commons,
2016-12-01 15:23:03 +01:00
IdHTTPWebBrokerBridge,
CustomersControllerU in 'CustomersControllerU.pas',
WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule} ,
2016-12-01 15:23:03 +01:00
CustomersTDGU in 'CustomersTDGU.pas' {CustomersTDG: TDataModule};
{$R *.res}
procedure RunServer(APort: Integer);
var
LServer: TIdHTTPWebBrokerBridge;
begin
Writeln('** DMVCFramework Server ** ' + DMVCFRAMEWORK_VERSION);
2016-12-01 15:23:03 +01:00
Writeln(Format('Starting HTTP Server on port %d', [APort]));
LServer := TIdHTTPWebBrokerBridge.Create(nil);
try
LServer.DefaultPort := APort;
LServer.Active := True;
{ more info about MaxConnections
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_MaxConnections.html }
2016-12-01 15:23:03 +01:00
LServer.MaxConnections := 0;
{ more info about ListenQueue
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_ListenQueue.html }
2016-12-01 15:23:03 +01:00
LServer.ListenQueue := 200;
{ Comment the next line to avoid the default browser startup }
ShellExecute(0, 'open', PChar('http://localhost:' + inttostr(APort)), nil, nil, SW_SHOWMAXIMIZED);
Writeln('Press RETURN to stop the server');
ReadLn;
2016-12-01 15:23:03 +01:00
finally
LServer.Free;
end;
end;
begin
SetupFireDACConnection;
ReportMemoryLeaksOnShutdown := True;
try
if WebRequestHandler <> nil then
WebRequestHandler.WebModuleClass := WebModuleClass;
WebRequestHandlerProc.MaxConnections := 1024;
RunServer(8080);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
2016-12-01 15:23:03 +01:00
end.