webdemo.pp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. program webdemo;
  2. {$mode objfpc}{$H+}
  3. uses
  4. fpmimetypes,sysutils, httproute, fphttpapp, regreports, wmreports, fpwebfile;
  5. Procedure RegisterModules(Const StartFile : String);
  6. begin
  7. TPageReportModule.RegisterModule('Page',True);
  8. TGenerateReportModule.RegisterModule('Generate',True);
  9. TViewReportModule.RegisterModule('View',True);
  10. TReportListModule.RegisterModule('ReportList',True);
  11. if (StartFile<>'') then
  12. RegisterFileLocation('Start',ExtractFilePath(StartFile));
  13. HTTPRouter.RegisterRoute('/*',@ShowPage,true);
  14. end;
  15. begin
  16. {$ifndef windows}
  17. MimeTypesFile:='/etc/mime.types';
  18. {$endif}
  19. With Application do
  20. begin
  21. Port:=8080;
  22. AllowDefaultModule:=True;
  23. RegisterModules(GetOptionValue('s','start'));
  24. DefaultModuleName:='Page';
  25. if IsConsole then
  26. begin
  27. Writeln('Point your browser to http://localhost:',Port,'/Page or http://localhost:',Port);
  28. if HasOption('s','start') then
  29. Writeln('An alternate start location is available at http://localhost:',Port,'/Start/',ExtractFileName(GetOptionValue('s','start')));
  30. end;
  31. PreferModuleName:=True;
  32. Initialize;
  33. Run;
  34. end;
  35. end.