20 lines
1.2 KiB
JavaScript
20 lines
1.2 KiB
JavaScript
const http = require('http');
|
|
|
|
const PORT = process.env.PORT || 8080;
|
|
const hostname = process.env.HOSTNAME || '0.0.0.0';
|
|
|
|
const server = http.createServer((req, res) => {
|
|
const path = req.url === '/' ? '/index.html' : req.url;
|
|
const status = path === '/index.html' || path === '/health' ? 200 : 404;
|
|
const body = path === '/health'
|
|
? 'ok\n'
|
|
: `<!doctype html><html lang="ar" dir="rtl"><head><meta charset="utf-8"><title>غيمة · تجريبي</title></head><body style="font-family:sans-serif;max-width:40em;margin:4em auto;padding:0 1em;line-height:1.9"><h1>يعمل من Git 🎉</h1><p>هذا تطبيق تجريبي نُشر من مستودع عبر النشر من Git.</p><p><strong>الإصدار 2</strong> — بُني تلقائياً عبر الويب هوك بعد push.</p><p><code>req.url</code> = ${path} · <code>status</code> = ${status}</p><p>أُعيد نشره تلقائياً عند كل push على الفرع الرئيسي.</p></body></html>\n`;
|
|
|
|
res.writeHead(status, { 'Content-Type': path === '/health' ? 'text/plain' : 'text/html; charset=utf-8' });
|
|
res.end(body);
|
|
});
|
|
|
|
server.listen(PORT, hostname, () => {
|
|
console.log(`ghaymah-demo listening on http://${hostname}:${PORT}`);
|
|
});
|