// Zero-dependency static server for the Synthia Arsenal directory (HF Docker Space). const http = require('http'); const fs = require('fs'); const path = require('path'); const PORT = process.env.PORT || 7860; const ROOT = path.join(__dirname, 'public'); const TYPES = { '.html':'text/html; charset=utf-8', '.js':'text/javascript; charset=utf-8', '.css':'text/css; charset=utf-8', '.json':'application/json; charset=utf-8', '.svg':'image/svg+xml', '.png':'image/png', '.ico':'image/x-icon', '.txt':'text/plain; charset=utf-8' }; http.createServer((req, res) => { if (req.url === '/healthz') { res.writeHead(200, {'Content-Type':'text/plain'}); return res.end('ok'); } let p = decodeURIComponent(req.url.split('?')[0]); if (p === '/' || p === '') p = '/index.html'; const file = path.normalize(path.join(ROOT, p)); if (!file.startsWith(ROOT)) { res.writeHead(403); return res.end('forbidden'); } fs.readFile(file, (err, buf) => { if (err) { res.writeHead(404, {'Content-Type':'text/html'}); return res.end('

404

'); } const ext = path.extname(file).toLowerCase(); const headers = {'Content-Type': TYPES[ext] || 'application/octet-stream'}; if (ext === '.html') headers['Cache-Control'] = 'no-cache'; else headers['Cache-Control'] = 'public, max-age=3600'; res.writeHead(200, headers); res.end(buf); }); }).listen(PORT, '0.0.0.0', () => console.log('Synthia Arsenal on :' + PORT));