2013-10-29 16:51:16 +01:00
|
|
|
unit WebModuleUnit1;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses System.SysUtils,
|
|
|
|
System.Classes,
|
|
|
|
Web.HTTPApp,
|
|
|
|
MVCFramework;
|
|
|
|
|
|
|
|
type
|
|
|
|
TWebModule1 = class(TWebModule)
|
|
|
|
procedure WebModuleCreate(Sender: TObject);
|
|
|
|
|
|
|
|
private
|
|
|
|
MVC: TMVCEngine;
|
|
|
|
|
|
|
|
{ Private declarations }
|
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
WebModuleClass: TComponentClass = TWebModule1;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2020-03-05 18:34:00 +01:00
|
|
|
uses
|
|
|
|
FileUploadControllerU,
|
|
|
|
MVCFramework.Commons,
|
2024-04-10 17:12:42 +02:00
|
|
|
MVCFramework.View.Renderers.Mustache,
|
2020-04-29 01:59:41 +02:00
|
|
|
MVCFramework.Middleware.Trace,
|
|
|
|
MVCFramework.Middleware.StaticFiles;
|
2013-10-29 16:51:16 +01:00
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
2020-03-05 18:34:00 +01:00
|
|
|
|
2013-10-29 16:51:16 +01:00
|
|
|
procedure TWebModule1.WebModuleCreate(Sender: TObject);
|
|
|
|
begin
|
2020-05-11 23:39:43 +02:00
|
|
|
MVC := TMVCEngine.Create(self,
|
|
|
|
procedure(Config: TMVCConfig)
|
|
|
|
begin
|
|
|
|
Config[TMVCConfigKey.ViewPath] :=
|
2024-04-10 17:12:42 +02:00
|
|
|
ExtractFilePath(GetModuleName(HInstance)) + '..\templates';
|
2020-05-11 23:39:43 +02:00
|
|
|
Config[TMVCConfigKey.DefaultContentType] := TMVCMediaType.TEXT_HTML;
|
|
|
|
end);
|
2013-10-29 16:51:16 +01:00
|
|
|
MVC.AddController(TFileUploadController);
|
2020-04-29 01:59:41 +02:00
|
|
|
MVC.AddMiddleware(TMVCStaticFilesMiddleware.Create(
|
2021-11-05 09:53:01 +01:00
|
|
|
'/static', { StaticFilesPath }
|
2024-04-10 17:12:42 +02:00
|
|
|
ExtractFilePath(GetModuleName(HInstance)) + '..\www', { DocumentRoot }
|
2020-05-11 23:39:43 +02:00
|
|
|
'index.html' { IndexDocument - Before it was named fallbackresource }
|
2020-04-29 01:59:41 +02:00
|
|
|
));
|
2024-04-10 17:12:42 +02:00
|
|
|
MVC.SetViewEngine(TMVCMustacheViewEngine);
|
2013-10-29 16:51:16 +01:00
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|