kalp-dolasim/server.js

27 lines
904 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// İnsan Dolaşım & Sinir Sistemi Simülasyonu — statik sunucu
// public/ klasöründeki canvas uygulamasını servis eder.
// Port: işletim sistemi otomatik boş port atar (EADDRINUSE imkânsız).
const express = require('express');
const path = require('path');
const app = express();
// Statik dosyalar (index.html, app.js, style.css)
app.use(express.static(path.join(__dirname, 'public')));
// Health check — sunucunun ayakta olduğunu doğrulamak için
app.get('/api/health', (req, res) => {
res.json({ durum: 'ok', zaman: new Date().toISOString() });
});
// Ana sayfa
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// 0 = boş bir port ver — gerçek portu address().port'tan al
const server = app.listen(0, () => {
const port = server.address().port;
console.log(`♥ Kalp & Dolaşım Simülasyonu http://localhost:${port}`);
});