about request handled in server.
This commit is contained in:
parent
a2340544b6
commit
65b63e2b0f
13
server.js
13
server.js
@ -33,6 +33,19 @@ const server = http.createServer((req, res) => {
|
|||||||
res.end();
|
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;
|
const port = process.env.port || 9000;
|
||||||
|
Loading…
Reference in New Issue
Block a user