From fd579de89822980fc6164a0651fe6d9458c2bf0a Mon Sep 17 00:00:00 2001 From: sweatshirt0 Date: Fri, 27 Jan 2023 00:00:10 -0500 Subject: [PATCH] figured out css loading and styling patch 1 for home page. --- index.html | 16 ---------------- pages/index.html | 4 ++++ server.js | 30 +++++++++++++++++++++++++++--- styles/styles.css | 8 ++++++++ 4 files changed, 39 insertions(+), 19 deletions(-) delete mode 100644 index.html create mode 100644 styles/styles.css diff --git a/index.html b/index.html deleted file mode 100644 index a8577be..0000000 --- a/index.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - Libcasa-Chan - - -
- -
-

Home

-
-
- - diff --git a/pages/index.html b/pages/index.html index 453255a..7fe43fb 100644 --- a/pages/index.html +++ b/pages/index.html @@ -1,7 +1,9 @@ + Libcasa-Chan +
@@ -12,6 +14,8 @@

Home

+
+
diff --git a/server.js b/server.js index bda14ae..aa2dd20 100644 --- a/server.js +++ b/server.js @@ -2,10 +2,19 @@ const http = require("http"); const fs = require("fs"); 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) { + res.write(data); + res.end(); + }); + } + if (req.url === "/") { res.statusCode = 200; res.setHeader("Content-Type", "text/html"); - fs.readFile("index.html", function(error, data) { + fs.readFile("./pages/index.html", function(error, data) { if (error) { res.writeHead(404); res.write("Error: File not found."); @@ -13,9 +22,24 @@ const server = http.createServer((req, res) => { 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) { + if (error) { + res.writeHead(404); + res.write("Error: File not found."); + } else { + res.write(data); + } + res.end(); + }); + } + +}); const port = process.env.port || 8000; diff --git a/styles/styles.css b/styles/styles.css new file mode 100644 index 0000000..c272186 --- /dev/null +++ b/styles/styles.css @@ -0,0 +1,8 @@ +body { + background-color: black; + font-family: sans-serif; +} + +.title { + color: white; +}