delphimvcframework/samples/routingsample/routingsample.dpr

57 lines
1.4 KiB
ObjectPascal
Raw Normal View History

2013-11-09 10:32:54 +01:00
program routingsample;
{$APPTYPE CONSOLE}
2014-03-06 14:20:57 +01:00
2013-11-09 10:32:54 +01:00
uses
System.SysUtils,
Winapi.Windows,
IdHTTPWebBrokerBridge,
Web.WebReq,
Web.WebBroker,
2014-03-06 14:20:57 +01:00
WebModuleU in 'WebModuleU.pas' {WebModule1: TWebModule} ,
2013-11-10 01:03:53 +01:00
RoutingSampleControllerU in 'RoutingSampleControllerU.pas',
BusinessObjectsU in 'BusinessObjectsU.pas';
2013-11-09 10:32:54 +01:00
{$R *.res}
2014-03-06 14:20:57 +01:00
2013-11-09 10:32:54 +01:00
procedure RunServer(APort: Integer);
var
LInputRecord: TInputRecord;
LEvent: DWord;
LHandle: THandle;
LServer: TIdHTTPWebBrokerBridge;
begin
Writeln(Format('Starting HTTP Server or port %d', [APort]));
LServer := TIdHTTPWebBrokerBridge.Create(nil);
try
LServer.DefaultPort := APort;
LServer.Active := True;
2014-03-06 14:20:57 +01:00
LServer.ServerSoftware := 'DMVCFramework';
2013-11-09 10:32:54 +01: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
2014-03-06 14:20:57 +01:00
LInputRecord.Event.KeyEvent.bKeyDown and
(LInputRecord.Event.KeyEvent.wVirtualKeyCode = VK_ESCAPE) then
2013-11-09 10:32:54 +01:00
break;
end;
finally
LServer.Free;
end;
end;
begin
try
2014-03-06 14:20:57 +01:00
if WebRequestHandler <> nil then
WebRequestHandler.WebModuleClass := WebModuleClass;
2013-11-09 10:32:54 +01:00
RunServer(8080);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end
2014-03-06 14:20:57 +01:00
2013-11-09 10:32:54 +01:00
end.