mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 00:05:53 +01:00
86 lines
3.9 KiB
ObjectPascal
86 lines
3.9 KiB
ObjectPascal
program TestServer;
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
|
uses
|
|
System.SysUtils,
|
|
IdHTTPWebBrokerBridge,
|
|
Web.WebReq,
|
|
{$IFNDEF LINUX}
|
|
Winapi.Windows,
|
|
{$ENDIF }
|
|
Web.WebBroker,
|
|
MVCFramework.Commons,
|
|
MVCFramework.Console,
|
|
WebModuleUnit in 'WebModuleUnit.pas' {MainWebModule: TWebModule},
|
|
TestServerControllerU in 'TestServerControllerU.pas',
|
|
TestServerControllerExceptionU in 'TestServerControllerExceptionU.pas',
|
|
SpeedMiddlewareU in 'SpeedMiddlewareU.pas',
|
|
TestServerControllerPrivateU in 'TestServerControllerPrivateU.pas',
|
|
AuthHandlersU in 'AuthHandlersU.pas',
|
|
BusinessObjectsU in '..\..\..\samples\commons\BusinessObjectsU.pas',
|
|
MVCFramework in '..\..\..\sources\MVCFramework.pas',
|
|
TestServerControllerJSONRPCU in 'TestServerControllerJSONRPCU.pas',
|
|
MVCFramework.JSONRPC in '..\..\..\sources\MVCFramework.JSONRPC.pas',
|
|
RandomUtilsU in '..\..\..\samples\commons\RandomUtilsU.pas',
|
|
MVCFramework.Serializer.JsonDataObjects.OptionalCustomTypes in '..\..\..\sources\MVCFramework.Serializer.JsonDataObjects.OptionalCustomTypes.pas';
|
|
|
|
{$R *.res}
|
|
|
|
|
|
procedure Logo;
|
|
begin
|
|
SetMode(TConsoleMode.Bright);
|
|
TextBackground(TConsoleColor.Black);
|
|
TextColor(TConsoleColor.Red);
|
|
WriteLn(' ██████╗ ███╗ ███╗██╗ ██╗ ██████╗ ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗');
|
|
WriteLn(' ██╔══██╗████╗ ████║██║ ██║██╔════╝ ██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗');
|
|
WriteLn(' ██║ ██║██╔████╔██║██║ ██║██║ ███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝');
|
|
WriteLn(' ██║ ██║██║╚██╔╝██║╚██╗ ██╔╝██║ ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗');
|
|
WriteLn(' ██████╔╝██║ ╚═╝ ██║ ╚████╔╝ ╚██████╗ ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║');
|
|
WriteLn(' ╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝');
|
|
WriteLn(' ');
|
|
TextColor(TConsoleColor.Yellow);
|
|
WriteLn('DMVCFRAMEWORK VERSION: ', DMVCFRAMEWORK_VERSION);
|
|
TextColor(TConsoleColor.White);
|
|
end;
|
|
|
|
procedure RunServer(APort: Integer);
|
|
var
|
|
LServer: TIdHTTPWebBrokerBridge;
|
|
begin
|
|
Logo;
|
|
WriteLn(Format('Starting HTTP Server or port %d', [APort]));
|
|
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
|
try
|
|
LServer.OnParseAuthentication := TMVCParseAuthentication.OnParseAuthentication;
|
|
LServer.DefaultPort := APort;
|
|
LServer.Active := True;
|
|
{ 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;
|
|
WriteLn('Press RETURN to stop the server');
|
|
ReadLn;
|
|
WriteLn('Server stopped');
|
|
finally
|
|
LServer.Free;
|
|
end;
|
|
end;
|
|
|
|
begin
|
|
ReportMemoryLeaksOnShutdown := True;
|
|
try
|
|
if WebRequestHandler <> nil then
|
|
WebRequestHandler.WebModuleClass := WebModuleClass;
|
|
RunServer(9999);
|
|
except
|
|
on E: Exception do
|
|
WriteLn(E.ClassName, ': ', E.Message);
|
|
end
|
|
|
|
end.
|