2016-05-19 12:07:38 +02:00
|
|
|
program jwtplainserver;
|
|
|
|
|
2019-12-01 20:55:31 +01:00
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
2016-05-19 12:07:38 +02:00
|
|
|
|
|
|
|
uses
|
|
|
|
System.SysUtils,
|
|
|
|
Winapi.Windows,
|
|
|
|
Winapi.ShellAPI,
|
|
|
|
Web.WebReq,
|
|
|
|
Web.WebBroker,
|
|
|
|
IdHTTPWebBrokerBridge,
|
|
|
|
MyControllerU in 'MyControllerU.pas',
|
2019-12-01 20:55:31 +01:00
|
|
|
MainWebModuleU in 'MainWebModuleU.pas', MVCFramework.Commons {MyWebModule: TWebModule};
|
2016-05-19 12:07:38 +02:00
|
|
|
|
|
|
|
{$R *.res}
|
|
|
|
|
2019-12-01 20:55:31 +01:00
|
|
|
|
2016-05-19 12:07:38 +02:00
|
|
|
procedure RunServer(APort: Integer);
|
|
|
|
var
|
|
|
|
LInputRecord: TInputRecord;
|
|
|
|
LEvent: DWord;
|
|
|
|
LHandle: THandle;
|
|
|
|
LServer: TIdHTTPWebBrokerBridge;
|
|
|
|
begin
|
|
|
|
Writeln('** DMVCFramework Server **');
|
|
|
|
Writeln(Format('Starting HTTP Server on port %d', [APort]));
|
|
|
|
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
|
|
|
try
|
2019-12-01 20:55:31 +01:00
|
|
|
LServer.OnParseAuthentication := TMVCParseAuthentication.OnParseAuthentication;
|
2016-05-19 12:07:38 +02:00
|
|
|
LServer.DefaultPort := APort;
|
|
|
|
LServer.Active := True;
|
2019-12-01 20:55:31 +01:00
|
|
|
// ShellExecute(0, 'open', pChar('http://localhost:' + inttostr(APort)), nil, nil, SW_SHOWMAXIMIZED);
|
2016-05-19 12:07:38 +02:00
|
|
|
Writeln('Press ESC to stop the server');
|
|
|
|
LHandle := GetStdHandle(STD_INPUT_HANDLE);
|
|
|
|
while True do
|
|
|
|
begin
|
|
|
|
Win32Check(ReadConsoleInput(LHandle, LInputRecord, 1, LEvent));
|
|
|
|
if (LInputRecord.EventType = KEY_EVENT) and
|
|
|
|
LInputRecord.Event.KeyEvent.bKeyDown and
|
|
|
|
(LInputRecord.Event.KeyEvent.wVirtualKeyCode = VK_ESCAPE) then
|
|
|
|
break;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
LServer.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
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;
|
2019-12-01 20:55:31 +01:00
|
|
|
|
2016-05-19 12:07:38 +02:00
|
|
|
end.
|