| 123456789101112131415 |
- const http = require('http');
- const fs = require('fs');
- const path = require('path');
-
- const PORT = 8082;
-
- 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}`));
|