diff --git a/data/data.json b/data/data.json
new file mode 100644
index 0000000..542b2b9
--- /dev/null
+++ b/data/data.json
@@ -0,0 +1,12 @@
+[
+ {
+ "id": "1",
+ "username": "sweatshirt",
+ "password": "Daemons0!"
+ },
+ {
+ "id": "2",
+ "username": "samsepi0l",
+ "password": "Daemons0!"
+ }
+]
diff --git a/pages/home.html b/pages/home.html
new file mode 100644
index 0000000..a38b6d4
--- /dev/null
+++ b/pages/home.html
@@ -0,0 +1,14 @@
+
+
+
+
+ Anarchy Streams Logged In.
+
+
+
+
+
+
diff --git a/server.js b/server.js
index f0bb92c..015065b 100644
--- a/server.js
+++ b/server.js
@@ -1,6 +1,7 @@
const http = require("http");
const fs = require("fs");
const qs = require("querystring");
+const db = require("./data/data.json");
const server = http.createServer((req, res) => {
if (req.url === "/styles/styles.css") {
@@ -33,6 +34,59 @@ const server = http.createServer((req, res) => {
});
}
+ if (req.url === "/home") {
+ res.statusCode = 200;
+ res.setHeader("Content-Type", "text/html");
+ fs.readFile("./pages/home.html", (error, data) => {
+ if (error) {
+ res.writeHead(404);
+ res.write("Error: File not found.");
+ } else {
+ res.write(data);
+ }
+
+ res.end();
+ });
+ }
+
+ if (req.url === "/wrong_info") {
+ res.statusCode = 200;
+ res.setHeader("Content-Type", "text/html");
+ fs.readFile("./pages/wronginfo.html", (error, data) => {
+ if (error) {
+ res.writeHead(404);
+ res.write("Error: File not found.");
+ } else {
+ res.write(data);
+ }
+
+ res.end();
+ });
+ }
+
+ if (req.url === "/members" && req.method === "POST") {
+ res.statusCode = 200;
+ //res.setHeader("Content-Type", "text/json");
+ var body = "";
+
+ req.on("data", (data) => {
+ body = body + data;
+ });
+
+ req.on("end", () => {
+ var post = qs.parse(body);
+ db.forEach(i => {
+ if (post.username === i.username && post.password === i.password) {
+ res.writeHead(301, { Location: "/home" });
+ } else {
+ res.writeHead(301, { Location: "/wrong_info" });
+ }
+ });
+
+ res.end();
+ });
+ }
+
});
const port = process.env.port || 9000
diff --git a/styles/styles.css b/styles/styles.css
index 0c56af8..55fbcf9 100644
--- a/styles/styles.css
+++ b/styles/styles.css
@@ -22,14 +22,14 @@ body {
.title-wrapper {
position: relative;
top: 150px;
- left: 40px;
+ left: 5vw;
font-size: 1rem;
}
.subtitle-wrapper {
position: relative;
top: 155px;
- left: 40px;
+ left: 5vw;
font-size: 0.95rem;
}