import http from "node:http"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; const root = path.join(path.dirname(fileURLToPath(import.meta.url)), "runs"); const TYPES = { ".html": "text/html", ".json": "application/json", ".mp4": "video/mp4", ".png": "image/png" }; http.createServer((req, res) => { let p = decodeURIComponent((req.url || "/").split("?")[0]); if (p === "/" || p === "") p = "/index.html"; const fp = path.normalize(path.join(root, p)); if (!fp.startsWith(root)) { res.writeHead(403); return res.end(); } let st; try { st = fs.statSync(fp); } catch { res.writeHead(404); return res.end("not found"); } const type = TYPES[path.extname(fp)] || "application/octet-stream"; const range = req.headers.range; if (range) { // range support so