Pictures!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fileserver.js 619B

12345678910111213141516171819202122232425262728293031
  1. var fs = require("fs");
  2. var pathlib = require("path");
  3. var webroot = "web";
  4. var files = {};
  5. function file(wpath, fpath) {
  6. if (fpath === undefined)
  7. fpath = wpath;
  8. files[wpath] = fs.readFileSync(pathlib.join(webroot, fpath));
  9. }
  10. file("/polyfills.js");
  11. file("/script.js");
  12. file("/slide.css");
  13. file("/slide.js");
  14. file("/admin/", "/admin/index.html");
  15. file("/admin/style.css");
  16. file("/admin/lib.js");
  17. file("/admin/view.js");
  18. exports.canServe = canServe;
  19. function canServe(parts) {
  20. return files[parts.pathname] !== undefined;
  21. }
  22. exports.serve = serve;
  23. function serve(parts, res) {
  24. res.end(files[parts.pathname]);
  25. }