delphimvcframework/samples/serversideviews/ServerSideViewsEx.dpr

64 lines
1.1 KiB
ObjectPascal
Raw Normal View History

2016-11-27 23:17:20 +01:00
program ServerSideViewsEx;
2017-05-09 23:13:51 +02:00
2016-11-27 23:17:20 +01:00
{$APPTYPE CONSOLE}
uses
System.SysUtils,
2017-05-09 23:13:51 +02:00
{$IFDEF MSWINDOWS}
2016-11-27 23:17:20 +01:00
Winapi.ShellAPI,
Winapi.Windows,
2017-05-09 23:13:51 +02:00
{$ENDIF}
2016-11-27 23:17:20 +01:00
IdHTTPWebBrokerBridge,
Web.WebReq,
Web.WebBroker,
WebModuleU in 'WebModuleU.pas' {WebModule1: TWebModule} ,
WebSiteControllerU in 'WebSiteControllerU.pas',
DAL in 'DAL.pas';
{$R *.res}
procedure RunServer(APort: Integer);
var
LInputRecord: TInputRecord;
LEvent: DWord;
LHandle: THandle;
LServer: TIdHTTPWebBrokerBridge;
begin
ReportMemoryLeaksOnShutdown := True;
Writeln(Format('Starting HTTP Server on port %d', [APort]));
LServer := TIdHTTPWebBrokerBridge.Create(nil);
try
LServer.DefaultPort := APort;
LServer.Active := True;
2017-05-09 23:13:51 +02:00
Writeln('Press RETURN to stop the server');
{$IFDEF MSWINDOWS}
2016-11-27 23:17:20 +01:00
ShellExecute(0, 'open', 'http://localhost:8080', nil, nil, SW_SHOW);
2017-05-09 23:13:51 +02:00
{$ENDIF}
ReadLn;
2016-11-27 23:17:20 +01:00
finally
LServer.Free;
end;
end;
begin
try
if WebRequestHandler <> nil then
WebRequestHandler.WebModuleClass := WebModuleClass;
RunServer(8080);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.