const http = require('http'); const fs = require('fs'); const path = require('path'); const PORT = 3000; const PUBLIC_DIR = path.join(__dirname, 'public'); const server = http.createServer((req, res) => { let filePath = path.join(PUBLIC_DIR, req.url === '/' ? 'index.html' : req.url); // Set CORS headers for PWA res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); res.setHeader('Access-Control-Allow-Headers', 'Content-Type'); // Set cache headers for icons and manifest if (req.url.includes('.png') || req.url.includes('.json') || req.url.includes('.svg')) { res.setHeader('Cache-Control', 'public, max-age=31536000'); } const ext = path.extname(filePath); const contentTypes = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.json': 'application/json', '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.woff': 'font/woff', '.woff2': 'font/woff2', }; const contentType = contentTypes[ext] || 'application/octet-stream'; fs.readFile(filePath, (err, content) => { if (err) { if (err.code === 'ENOENT') { res.writeHead(404, { 'Content-Type': 'text/html' }); res.end('