commit f702e7a004d2b546633c4d60dbe26b86ae0d68ed Author: Benjamyn Love Date: Fri Jan 31 09:13:26 2020 +1100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..972062a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +env/ +.vscode/ \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..81dfda3 --- /dev/null +++ b/main.py @@ -0,0 +1,38 @@ +from flask import Flask, render_template, request, abort +import json +import html + +app = Flask(__name__) +app.config["DEBUG"] = True + +@app.route("/", methods=["GET", "POST"]) +def index(): + buttons = {0: "418 error",1: "Json Reply",2: "Admin"} + users = [["benjamyn", 1], ["Test Case", 0]] + data = {"buttons": buttons, "users": users} + if request.method == "POST": + jsonData = json.loads(request.data) + if "button" in jsonData: + if jsonData["button"] == '0': + return abort(418) + elif jsonData["button"] == '1': + return json.dumps({"This is a test response": 1, "status": "Success"}) + elif jsonData["button"] == '2': + return render_template("admin.html", data=data) + return f"{buttons[int(jsonData['button'])]} was pressed" + return render_template("testing.html", data=data) + return render_template("index.html", data=data) + +@app.route("/otherpage", methods=["POST", "GET"]) +def otherpage(): + buttons = {0: "Other",1: "Pages",2: "Same",3: "Template"} + data = {"buttons": buttons} + if request.method == "POST": + jsonData = json.loads(request.data) + if jsonData["button"] == '0': + return render_template("list.html", data=data) + return jsonData + return render_template("index.html", data=data) + +if __name__ == '__main__': + app.run(host="0.0.0.0") \ No newline at end of file diff --git a/static/css/main.css b/static/css/main.css new file mode 100644 index 0000000..3a805ab --- /dev/null +++ b/static/css/main.css @@ -0,0 +1,57 @@ +.sidebar { + background-color: #2a2a2a; + position: fixed; + top: 0px; + left: 0px; + width: 15em; + height: 100%; + border-right: 1px dashed black; +} + +.navbutton { + text-align: center; + padding-left: 2px; + border-left: 1px solid dimgray; + border-right: 1px solid dimgray; +} + +#navbar { + position: absolute; + bottom: 0; +} + +.content { + padding-left: 16em; + padding-right: 1em; + padding-top: 6em; + width: 100%; +} + +.header { + position: fixed; + top: 0px; + left: 15em; + width: 100%; + height: 5em; + background-color: #2a2a2a; +} + +.std { + color: azure; + background-color: #2a2a2a; +} + +.fixed{ + position:fixed; + top:0px; + left: 15em; + width:100px; +} + +#header { + border-top: 1px solid azure; +} + +body { + background-color: slategray; +} \ No newline at end of file diff --git a/static/images/logo.png b/static/images/logo.png new file mode 100644 index 0000000..51b1b60 Binary files /dev/null and b/static/images/logo.png differ diff --git a/static/js/call.js b/static/js/call.js new file mode 100644 index 0000000..9111ae4 --- /dev/null +++ b/static/js/call.js @@ -0,0 +1,11 @@ +function makeCall(btn) { + let makePost = new XMLHttpRequest(); + postData = { "button": btn }; + makePost.onreadystatechange = function () { + if (makePost.readyState === 4) { + document.getElementById("content").innerHTML = makePost.response; + } + } + makePost.open("POST", window.location.href, true); + makePost.send(JSON.stringify(postData)); +} \ No newline at end of file diff --git a/templates/admin.html b/templates/admin.html new file mode 100644 index 0000000..2efc4b2 --- /dev/null +++ b/templates/admin.html @@ -0,0 +1,59 @@ + +

LIST USERS

+
+ + + + + + + + + + {% for x in data["users"] %} + + + + + + {% endfor %} + +
UsernameAdminChange Password
{{x[0]}}{% if x[1] == 1 %} Yes {% else %} No {% endif %}
+
+
+

ADD NEW USERS

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+ +
+ + + + + + + + + \ No newline at end of file diff --git a/templates/default.html b/templates/default.html new file mode 100644 index 0000000..fa4b413 --- /dev/null +++ b/templates/default.html @@ -0,0 +1,52 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ItemRequesterGottem?Remove
Water, 1 slabBenjamyn +
+
+
+ +
+
V niceLuke +
+
+ +
Pretty quick tooLuke +
+
+ +
+
\ No newline at end of file diff --git a/templates/header.html b/templates/header.html new file mode 100644 index 0000000..64c2ae5 --- /dev/null +++ b/templates/header.html @@ -0,0 +1,29 @@ + + + + + + + + Test page + + + + + +
+ +
\ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..86eb931 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,21 @@ +{% include "header.html" %} + + {% include "sidebar.html" %} +
+

Press an option on the left to begin

+
+ + + + + + + + + \ No newline at end of file diff --git a/templates/list.html b/templates/list.html new file mode 100644 index 0000000..5aeb0bd --- /dev/null +++ b/templates/list.html @@ -0,0 +1,25 @@ + + + + + + + + + {% for x in data["buttons"] %} + + + + + + {% endfor %} + +
ItemRequester
{{data["buttons"][x]}}{{x}} +
+
+
+ +
+
\ No newline at end of file diff --git a/templates/otherpage.html b/templates/otherpage.html new file mode 100644 index 0000000..bfe3c05 --- /dev/null +++ b/templates/otherpage.html @@ -0,0 +1,70 @@ + + + + + + + + Test page + + + + + + +
+ +
+ +
+ COOOONENT +
+ + + + + + + + \ No newline at end of file diff --git a/templates/sidebar.html b/templates/sidebar.html new file mode 100644 index 0000000..58479ee --- /dev/null +++ b/templates/sidebar.html @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/templates/testing.html b/templates/testing.html new file mode 100644 index 0000000..d7c3d34 --- /dev/null +++ b/templates/testing.html @@ -0,0 +1,5 @@ + + Testing page + This is neat + + \ No newline at end of file