Appearance
const fs = require('fs');
const http = require('http');
const path = require('path');
http.createServer((req, res) => {
const filePath = path.join(__dirname, req.url);
fs.stat(filePath, (err, stats) => {
if (!err && stats.isFile()) {
res.writeHead(200);
fs.createReadStream(filePath).pipe(res);
} else {
res.writeHead(404);
res.end('Not Found');
}
});
}).listen(3000);