2023-01-27 00:55:29 +01:00
|
|
|
const http = require("http");
|
|
|
|
const fs = require("fs");
|
|
|
|
|
|
|
|
const server = http.createServer((req, res) => {
|
2023-01-27 06:00:10 +01:00
|
|
|
if (req.url === "/styles/styles.css" ) {
|
|
|
|
res.statusCode = 200;
|
|
|
|
res.setHeader("Content-Type", "text/css");
|
|
|
|
fs.readFile("styles/styles.css", function(error, data) {
|
|
|
|
res.write(data);
|
|
|
|
res.end();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-01-27 00:55:29 +01:00
|
|
|
if (req.url === "/") {
|
|
|
|
res.statusCode = 200;
|
|
|
|
res.setHeader("Content-Type", "text/html");
|
2023-01-27 06:00:10 +01:00
|
|
|
fs.readFile("./pages/index.html", function(error, data) {
|
|
|
|
if (error) {
|
|
|
|
res.writeHead(404);
|
|
|
|
res.write("Error: File not found.");
|
|
|
|
} else {
|
|
|
|
res.write(data);
|
|
|
|
}
|
|
|
|
res.end();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (req.url === "/about") {
|
|
|
|
res.statusCode = 200;
|
|
|
|
res.setHeader("Content-Type", "text/html");
|
|
|
|
fs.readFile("./pages/about.html", function(error, data) {
|
2023-01-27 00:55:29 +01:00
|
|
|
if (error) {
|
|
|
|
res.writeHead(404);
|
|
|
|
res.write("Error: File not found.");
|
|
|
|
} else {
|
|
|
|
res.write(data);
|
|
|
|
}
|
|
|
|
res.end();
|
2023-01-27 06:00:10 +01:00
|
|
|
});
|
2023-01-27 00:55:29 +01:00
|
|
|
}
|
2023-01-27 06:00:10 +01:00
|
|
|
|
2023-01-27 06:51:41 +01:00
|
|
|
if (req.url === "/register") {
|
|
|
|
res.statusCode = 200;
|
|
|
|
res.setHeader("Content-Type", "text/html");
|
|
|
|
fs.readFile("./pages/register.html", function(error, data) {
|
|
|
|
if (error) {
|
|
|
|
res.writeHead(404);
|
|
|
|
res.write("Error: File not found.");
|
|
|
|
} else {
|
|
|
|
res.write(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
res.end();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-01-28 05:42:47 +01:00
|
|
|
if (req.url === "/libcasa-irc") {
|
|
|
|
res.statusCode = 200;
|
|
|
|
res.setHeader("Content-Type", "text/html");
|
|
|
|
fs.readFile("./pages/libcasa.html", function(error, data) {
|
|
|
|
if (error) {
|
|
|
|
res.writeHead(404);
|
|
|
|
res.write("Error: File not found.");
|
|
|
|
} else {
|
|
|
|
res.write(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
res.end();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-01-27 06:00:10 +01:00
|
|
|
});
|
2023-01-27 00:55:29 +01:00
|
|
|
|
|
|
|
const port = process.env.port || 8000;
|
|
|
|
|
|
|
|
server.listen(port, () => console.log(`Server running on port ${port}`));
|
|
|
|
|
|
|
|
|