diff --git a/404.html b/404.html new file mode 100644 index 0000000..64850ca --- /dev/null +++ b/404.html @@ -0,0 +1,20 @@ + + + + + + 404 + + +
+
+
+ Home + About + Contact Me +
+
+ Whoops! Page not found! +
+ + diff --git a/about.html b/about.html new file mode 100644 index 0000000..f0b0c68 --- /dev/null +++ b/about.html @@ -0,0 +1,20 @@ + + + + + + About + + +
+
+
+ Home + About + Contact Me +
+
+ About me: I made this website +
+ + diff --git a/contact-me.html b/contact-me.html new file mode 100644 index 0000000..a084bb6 --- /dev/null +++ b/contact-me.html @@ -0,0 +1,20 @@ + + + + + + Contact Me + + +
+
+
+ Home + About + Contact Me +
+
+ This is where my contact information would be +
+ + diff --git a/index.html b/index.html new file mode 100644 index 0000000..5ca6491 --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + + Index + + +
+
+
+ Home + About + Contact Me +
+
+ Welcome to the home page! +
+ + diff --git a/index.js b/index.js new file mode 100644 index 0000000..c3a0f91 --- /dev/null +++ b/index.js @@ -0,0 +1,37 @@ +const http = require("node:http"); +const fs = require("node:fs"); + +const SERVER = http.createServer(); +const PORT = 8080; + +const HOME = fs.readFileSync("./index.html"); +const ABOUT = fs.readFileSync("./about.html"); +const CONTACT = fs.readFileSync("./contact-me.html"); +const ERROR = fs.readFileSync("./404.html"); + +SERVER.on("request", (req, res) => { + switch (req.url) { + case "/": + res.writeHead(200); + res.end(HOME); + break; + case "/index": + res.writeHead(200); + res.end(HOME); + break; + case "/about": + res.writeHead(200); + res.end(ABOUT); + break; + case "/contact-me": + res.writeHead(200); + res.end(CONTACT); + break; + default: + res.writeHead(404); + res.end(ERROR); + break; + } +}); + +SERVER.listen(PORT);