var fs = require("fs"); var pathlib = require("path"); var webroot = "web"; var files = {}; function file(wpath, fpath) { if (fpath === undefined) fpath = wpath; files[wpath] = fs.readFileSync(pathlib.join(webroot, fpath)); } file("/polyfills.js"); file("/script.js"); file("/slide.css"); file("/slide.js"); file("/admin/", "/admin/index.html"); file("/admin/style.css"); file("/admin/lib.js"); file("/admin/view.js"); exports.canServe = canServe; function canServe(parts) { return files[parts.pathname] !== undefined; } exports.serve = serve; function serve(parts, res) { res.end(files[parts.pathname]); }