2013-10-29 16:51:16 +01:00
|
|
|
program BasicDemo;
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
2016-06-22 17:49:16 +02:00
|
|
|
|
2013-10-29 16:51:16 +01:00
|
|
|
uses
|
|
|
|
System.SysUtils,
|
|
|
|
Web.WebReq,
|
|
|
|
Web.WebBroker,
|
|
|
|
IdHTTPWebBrokerBridge,
|
2024-03-14 15:03:51 +01:00
|
|
|
MVCFramework,
|
|
|
|
MVCFramework.Signal,
|
2017-04-14 17:28:18 +02:00
|
|
|
MVCFramework.Logger,
|
2020-04-24 02:48:39 +02:00
|
|
|
WebModuleUnit1 in 'WebModuleUnit1.pas' {WebModule1: TWebModule},
|
|
|
|
App1MainControllerU in 'App1MainControllerU.pas',
|
|
|
|
MVCFramework.Middleware.StaticFiles in '..\..\sources\MVCFramework.Middleware.StaticFiles.pas';
|
2013-10-29 16:51:16 +01:00
|
|
|
|
|
|
|
{$R *.res}
|
|
|
|
|
2016-06-22 17:49:16 +02:00
|
|
|
|
2013-10-29 16:51:16 +01:00
|
|
|
procedure RunServer(APort: Integer);
|
|
|
|
var
|
2017-04-14 16:43:31 +02:00
|
|
|
lServer: TIdHTTPWebBrokerBridge;
|
2013-10-29 16:51:16 +01:00
|
|
|
begin
|
2017-04-14 17:28:18 +02:00
|
|
|
// Writeln(Format('Starting HTTP Server or port %d', [APort]));
|
2013-10-29 16:51:16 +01:00
|
|
|
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
|
|
|
try
|
|
|
|
LServer.DefaultPort := APort;
|
2017-04-14 17:28:18 +02:00
|
|
|
LogI(Format('Server started on port %d', [APort]));
|
|
|
|
|
|
|
|
{ more info about MaxConnections
|
|
|
|
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_MaxConnections.html }
|
|
|
|
LServer.MaxConnections := 0;
|
|
|
|
|
|
|
|
{ more info about ListenQueue
|
|
|
|
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_ListenQueue.html }
|
|
|
|
LServer.ListenQueue := 200;
|
2024-03-14 15:03:51 +01:00
|
|
|
LServer.Active := True;
|
|
|
|
WriteLn('CTRL+C to shutdown the server');
|
|
|
|
WaitForTerminationSignal;
|
|
|
|
EnterInShutdownState;
|
2013-10-29 16:51:16 +01:00
|
|
|
finally
|
|
|
|
LServer.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
ReportMemoryLeaksOnShutdown := True;
|
|
|
|
try
|
|
|
|
if WebRequestHandler <> nil then
|
|
|
|
WebRequestHandler.WebModuleClass := WebModuleClass;
|
|
|
|
WebRequestHandlerProc.MaxConnections := 1024;
|
2017-05-25 16:57:49 +02:00
|
|
|
RunServer(8080);
|
2013-10-29 16:51:16 +01:00
|
|
|
except
|
|
|
|
on E: Exception do
|
|
|
|
Writeln(E.ClassName, ': ', E.Message);
|
2014-09-05 12:47:40 +02:00
|
|
|
end;
|
2013-10-29 16:51:16 +01:00
|
|
|
|
|
|
|
end.
|