news request handled in server.
This commit is contained in:
parent
65b63e2b0f
commit
9bfcf0ab87
15
server.js
15
server.js
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user