const http = require('http') const fs = require('fs') const path = require('path') const root = 'd:/workspace/code/fms' http .createServer((req, res) => { const urlPath = req.url === '/' ? '/.tmp-dnd-test.html' : decodeURIComponent(req.url.split('?')[0]) const fp = path.join(root, urlPath) fs.readFile(fp, (err, data) => { if (err) { res.writeHead(404) res.end('nf') return } res.writeHead(200, { 'Content-Type': fp.endsWith('.html') ? 'text/html; charset=utf-8' : 'text/plain' }) res.end(data) }) }) .listen(8090, '127.0.0.1') console.log('server on 8090')