const http = require('http'); const fs = require('fs'); const path = require('path'); const PORT = 8080; http.createServer((req, res) => { let fp = path.join(__dirname, req.url === '/' ? 'index.html' : req.url); const ext = path.extname(fp); const types = { '.html': 'text/html', '.css': 'text/css', '.js': 'application/javascript' }; fs.readFile(fp, (e, d) => { res.writeHead(e ? 404 : 200, { 'Content-Type': types[ext] || 'text/plain' }); res.end(e ? 'Not Found' : d); }); }).listen(PORT, () => console.log(`✅ 远程协作前端:http://localhost:${PORT}`));