Anarchy_Streaming/server.js
2023-02-18 12:10:28 -05:00

41 lines
872 B
JavaScript

const http = require("http");
const fs = require("fs");
const qs = require("querystring");
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", function(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", function(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
server.listen(port, () => console.log(`Server listening on port ${port}`));