treker-po-trenirovkam-i-pit.../server.js
Peppa 869a3d62e5
Some checks failed
peppa/test test: failure за 0с
ci / checks (pull_request) Failing after 10s
deploy / deploy (pull_request) Successful in 16s
TPTIP-8: трекер тренировок и питания (index.html, тесты, сервер стенда)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 15:27:58 +05:00

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');