delphimvcframework/samples/renders/renders.dpr

87 lines
2.8 KiB
ObjectPascal
Raw Normal View History

// ***************************************************************************
//
// Delphi MVC Framework
//
2019-01-08 12:48:27 +01:00
// Copyright (c) 2010-2019 Daniele Teti and the DMVCFramework Team
//
// https://github.com/danieleteti/delphimvcframework
//
// Collaborators with this file: Ezequiel Juliano Müller (ezequieljuliano@gmail.com)
//
// ***************************************************************************
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ***************************************************************************
2013-11-10 01:03:53 +01:00
program renders;
2013-11-10 01:03:53 +01:00
{$APPTYPE CONSOLE}
2019-03-10 16:29:18 +01:00
2013-11-10 01:03:53 +01:00
uses
System.SysUtils,
IdHTTPWebBrokerBridge,
MVCFramework.Commons,
2013-11-10 01:03:53 +01:00
Web.WebReq,
Web.WebBroker,
MVCFramework.Console,
WebModuleU in 'WebModuleU.pas' {WebModule1: TWebModule},
2013-11-10 01:03:53 +01:00
RenderSampleControllerU in 'RenderSampleControllerU.pas',
2016-11-27 23:17:20 +01:00
BusinessObjectsU in '..\commons\BusinessObjectsU.pas',
MyDataModuleU in 'MyDataModuleU.pas' {MyDataModule: TDataModule},
CustomTypesU in 'CustomTypesU.pas',
CustomTypesSerializersU in 'CustomTypesSerializersU.pas',
InMemoryDataU in 'InMemoryDataU.pas',
MVCFramework.DataSet.Utils in '..\..\sources\MVCFramework.DataSet.Utils.pas',
RandomUtilsU in '..\commons\RandomUtilsU.pas',
MVCFramework.Serializer.JsonDataObjects.OptionalCustomTypes in '..\..\sources\MVCFramework.Serializer.JsonDataObjects.OptionalCustomTypes.pas',
MVCFramework.Serializer.JsonDataObjects.CustomTypes in '..\..\sources\MVCFramework.Serializer.JsonDataObjects.CustomTypes.pas';
2013-11-10 01:03:53 +01:00
{$R *.res}
2019-03-10 16:29:18 +01:00
2013-11-10 01:03:53 +01:00
procedure RunServer(APort: Integer);
var
LServer: TIdHTTPWebBrokerBridge;
begin
Writeln(Format('Starting HTTP Server or port %d', [APort]));
LServer := TIdHTTPWebBrokerBridge.Create(nil);
try
LServer.DefaultPort := APort;
LServer.Active := True;
SetMode(TConsoleMode.Bright);
TextColor(Red);
Writeln('DMVCFRAMEWORK VERSION: ', DMVCFRAMEWORK_VERSION);
ResetConsole;
Writeln('Press RETURN to stop the server');
ReadLn;
Writeln('Stopping...');
2013-11-10 01:03:53 +01:00
finally
LServer.Free;
end;
end;
begin
2016-11-27 23:17:20 +01:00
ReportMemoryLeaksOnShutdown := True;
2013-11-10 01:03:53 +01:00
try
if WebRequestHandler <> nil then
WebRequestHandler.WebModuleClass := WebModuleClass;
RunServer(8080);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end
end.