const http = require("http");
const fs = require("fs");
const server = http.createServer((req, res) => {
res.setHeader("Content-Type", "text/html");
fs.readFile("./views/index.html", (err, data) => {
if (err) {
console.log(err);
} else {
res.end(data);
}
});
});
server.listen(3000, "localhost", () => {
console.log("listening for requests on port 3000");
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Full success</title>
</head>
<body>
<h1>Ladies and Gentlemans</h1>
<h2>We're in!</h2>
</body>
</html>
node server.js