15 lines
739 B
JavaScript
15 lines
739 B
JavaScript
// Мини-сервер для стенда: отдаёт index.html, /healthz отвечает 200. Слушает $PORT.
|
|
const http = require('node:http');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const page = path.join(__dirname, 'index.html');
|
|
http.createServer((req, res) => {
|
|
const url = (req.url || '/').split('?')[0];
|
|
if (url === '/healthz') { res.writeHead(200, { 'content-type': 'text/plain' }); return res.end('ok'); }
|
|
fs.readFile(page, (err, buf) => {
|
|
if (err) { res.writeHead(500); return res.end('error'); }
|
|
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache' });
|
|
res.end(buf);
|
|
});
|
|
}).listen(Number(process.env.PORT) || 3000, '0.0.0.0');
|