fix: 修复拖拽问题,松开鼠标结束拖动,互不影响
This commit is contained in:
28
server.js
Normal file
28
server.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
const filePath = req.url === '/' ? 'index.html' : req.url.slice(1);
|
||||
const ext = path.extname(filePath);
|
||||
const mimeTypes = {
|
||||
'.html': 'text/html',
|
||||
'.js': 'application/javascript',
|
||||
'.css': 'text/css'
|
||||
};
|
||||
|
||||
fs.readFile(path.join(process.cwd(), filePath), (err, data) => {
|
||||
if (err) {
|
||||
res.writeHead(404);
|
||||
res.end('Not Found');
|
||||
return;
|
||||
}
|
||||
res.writeHead(200, { 'Content-Type': mimeTypes[ext] || 'text/plain' });
|
||||
res.end(data);
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(0, () => {
|
||||
const port = server.address().port;
|
||||
console.log('Server running on http://localhost:' + port);
|
||||
});
|
||||
Reference in New Issue
Block a user