2013-10-29 16:51:16 +01:00
|
|
|
program FilesUploadDemo;
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
2014-03-03 15:05:01 +01:00
|
|
|
|
2013-10-29 16:51:16 +01:00
|
|
|
uses
|
|
|
|
System.SysUtils,
|
2017-05-09 23:13:51 +02:00
|
|
|
|
|
|
|
{$IFDEF MSWINDOWS}
|
|
|
|
|
2013-10-29 16:51:16 +01:00
|
|
|
Winapi.Windows,
|
|
|
|
Winapi.ShellAPI,
|
2017-05-09 23:13:51 +02:00
|
|
|
|
|
|
|
{$ENDIF}
|
|
|
|
|
2013-10-29 16:51:16 +01:00
|
|
|
IdHTTPWebBrokerBridge,
|
|
|
|
Web.WebReq,
|
|
|
|
Web.WebBroker,
|
2014-03-03 15:05:01 +01:00
|
|
|
ReqMulti, // if compiler doesn't find this unit, update with the last update
|
|
|
|
WebModuleUnit1 in 'WebModuleUnit1.pas' {WebModule1: TWebModule} ,
|
|
|
|
FileUploadControllerU in 'FileUploadControllerU.pas';
|
2013-10-29 16:51:16 +01:00
|
|
|
|
|
|
|
{$R *.res}
|
|
|
|
|
2014-03-03 15:05:01 +01:00
|
|
|
|
2013-10-29 16:51:16 +01:00
|
|
|
procedure RunServer(APort: Integer);
|
|
|
|
var
|
2014-03-03 15:05:01 +01:00
|
|
|
LServer: TIdHTTPWebBrokerBridge;
|
2013-10-29 16:51:16 +01:00
|
|
|
begin
|
2017-05-09 23:13:51 +02:00
|
|
|
|
|
|
|
{$IFDEF LINUX}
|
|
|
|
|
|
|
|
raise Exception.Create('This DEMO doesn''t work on linux due a bug in Delphi 10.2 Tokyo');
|
|
|
|
|
|
|
|
{$ENDIF}
|
|
|
|
|
2013-10-29 16:51:16 +01:00
|
|
|
Writeln(Format('Starting HTTP Server or 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}
|
|
|
|
|
2013-10-29 16:51:16 +01:00
|
|
|
ShellExecute(0, 'open', 'http://localhost:3000/fileupload.html', nil, nil, SW_SHOW);
|
2017-05-09 23:13:51 +02:00
|
|
|
|
|
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
ReadLn;
|
2013-10-29 16:51:16 +01:00
|
|
|
finally
|
|
|
|
LServer.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
if WebRequestHandler <> nil then
|
|
|
|
WebRequestHandler.WebModuleClass := WebModuleClass;
|
|
|
|
RunServer(3000);
|
|
|
|
except
|
|
|
|
on E: Exception do
|
|
|
|
Writeln(E.ClassName, ': ', E.Message);
|
|
|
|
end
|
|
|
|
|
|
|
|
end.
|