/** * Simple HTTP Server for Embryo Grading System * Node.js server to serve the application */ import http from 'http'; import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const PORT = 8000; // MIME types for different file extensions const mimeTypes = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.json': 'application/json', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.wasm': 'application/wasm', '.onnx': 'application/octet-stream', '.pt': 'application/octet-stream', '.safetensors': 'application/octet-stream' }; const server = http.createServer((req, res) => { console.log(`${new Date().toISOString()} - ${req.method} ${req.url}`); // Parse URL and remove query string let filePath = '.' + req.url.split('?')[0]; // Default to login.html instead of index.html if (filePath === './') { filePath = './login.html'; } // Get file extension const extname = String(path.extname(filePath)).toLowerCase(); const contentType = mimeTypes[extname] || 'application/octet-stream'; // Read and serve file fs.readFile(filePath, (error, content) => { if (error) { if (error.code === 'ENOENT') { // File not found res.writeHead(404, { 'Content-Type': 'text/html' }); res.end('