about request handled in server.

This commit is contained in:
sweatshirt0 2023-02-20 16:18:36 -05:00
parent a2340544b6
commit 65b63e2b0f

View File

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