智慧水务管理系统 - 精河县供水工程综合管理平台

serve-inventory.js 584B

123456789101112131415
  1. const http = require('http');
  2. const fs = require('fs');
  3. const path = require('path');
  4. const PORT = 8082;
  5. http.createServer((req, res) => {
  6. let fp = path.join(__dirname, req.url === '/' ? 'index.html' : req.url);
  7. const ext = path.extname(fp);
  8. const types = { '.html': 'text/html', '.css': 'text/css', '.js': 'application/javascript' };
  9. fs.readFile(fp, (e, d) => {
  10. res.writeHead(e ? 404 : 200, { 'Content-Type': types[ext] || 'text/plain' });
  11. res.end(e ? 'Not Found' : d);
  12. });
  13. }).listen(PORT, () => console.log(`✅ 库存管理前端:http://localhost:${PORT}`));