testhttp.pp 739 B

12345678910111213141516171819202122232425262728293031
  1. {$mode objfpc}
  2. {$H+}
  3. program testhttp;
  4. uses
  5. SysUtils, fphttpapp, fpwebfile, wmecho;
  6. Procedure Usage;
  7. begin
  8. Writeln('Usage : testhttp DocumentRoot [Port]');
  9. Writeln('Where');
  10. Writeln(' Documentroot location to serve files from. It is mapped to location /files');
  11. Writeln(' Port port to listen on (default 8080)');
  12. Halt(1);
  13. end;
  14. begin
  15. if (ParamCount<1) or (ParamCount>2) then
  16. usage;
  17. if (ParamCount=2) and (StrToIntDef(ParamStr(2),-1)=-1) then
  18. usage;
  19. RegisterFileLocation('files',ParamStr(1));
  20. {$ifdef unix}
  21. MimeTypesFile:='/etc/mime.types';
  22. {$endif}
  23. Application.Initialize;
  24. Application.Port:=StrTointDef(ParamStr(2),8080);
  25. Application.Title:='HTTP Demo application';
  26. Application.Run;
  27. end.