news request handled in server.

This commit is contained in:
sweatshirt0 2023-02-20 16:22:22 -05:00
parent 65b63e2b0f
commit 9bfcf0ab87
1 changed files with 15 additions and 0 deletions

View File

@ -46,6 +46,21 @@ const server = http.createServer((req, res) => {
} }
}); });
} }
if (req.url === "/news") {
res.statusCode = 200;
res.setHeader("Content-Type", "text/html");
fs.readFile("./pages/news.html", (error, data) => {
if (error) {
res.writeHead(404);
res.write("Error: File not found.");
} else {
res.write(data);
}
res.end();
});
}
}); });
const port = process.env.port || 9000; const port = process.env.port || 9000;