[Node] serve static and html files
Node.js
const http = require('http');
const fs = require('fs');
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/html');
const html = fs.readFileSync('index.html', 'utf8');
res.write(html);
res.end();
});
server.listen(8000);
Express
let indexPage = path.join(__dirname + '/public/index.html');
app.get('/', (req, res) => {
res.sendFile(indexPage);
});