2023-02-20 21:58:14 +01:00
|
|
|
const http = require("http");
|
|
|
|
const fs = require("fs");
|
|
|
|
const qs = require("querystring");
|
|
|
|
const dat = require("./data/data.json");
|
|
|
|
|
|
|
|
const server = http.createServer((req, res) => {
|
|
|
|
if (req.url === "/styles/styles.css") {
|
|
|
|
res.statusCode = 200;
|
|
|
|
res.setHeader("Content-Type", "text/css");
|
|
|
|
fs.readFile("./styles/styles.css", (error, data) => {
|
|
|
|
if (error) {
|
|
|
|
res.writeHead(404);
|
|
|
|
res.write("Error: File not found.");
|
|
|
|
} else {
|
|
|
|
res.write(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
res.end();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (req.url === "/") {
|
|
|
|
res.statusCode = 200;
|
|
|
|
res.setHeader("Content-Type", "text/html");
|
|
|
|
fs.readFile("./pages/landing.html", (error, data) => {
|
|
|
|
if (error) {
|
|
|
|
res.writeHead(404);
|
|
|
|
res.write("Error: File not found.");
|
|
|
|
} else {
|
|
|
|
res.write(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
res.end();
|
|
|
|
});
|
|
|
|
}
|
2023-02-20 22:18:36 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-02-20 22:22:22 +01:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
}
|
2023-02-20 21:58:14 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const port = process.env.port || 9000;
|
|
|
|
|
|
|
|
server.listen(port, () => console.log(`Server running on port ${port}`));
|