The fs.readFileSync function does not recognize the HTML-file, even tho it is localted in the same folder. The error says: Error: ENOENT: no such file or directory, open 'node.html'
const http = require('http');
const PORT = 3000;
const fs = require('fs')
const server = http.createServer((req, res) => {
if (req.url === '/') {
res.writeHead(200, {'content-type': 'text/html'});
const homePageHTML = fs.readFileSync('node.html');
console.log(homePageHTML)
res.end()
} else {
res.writeHead(404, {'content-type': 'text/html'});
res.write('<h1>Sorry, you were misled!</h1>')
res.end()
}
})
server.listen(PORT);