From f702e7a004d2b546633c4d60dbe26b86ae0d68ed Mon Sep 17 00:00:00 2001 From: Benjamyn Love Date: Fri, 31 Jan 2020 09:13:26 +1100 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ main.py | 38 +++++++++++++++++++++ static/css/main.css | 57 +++++++++++++++++++++++++++++++ static/images/logo.png | Bin 0 -> 2026 bytes static/js/call.js | 11 ++++++ templates/admin.html | 59 +++++++++++++++++++++++++++++++++ templates/default.html | 52 +++++++++++++++++++++++++++++ templates/header.html | 29 ++++++++++++++++ templates/index.html | 21 ++++++++++++ templates/list.html | 25 ++++++++++++++ templates/otherpage.html | 70 +++++++++++++++++++++++++++++++++++++++ templates/sidebar.html | 13 ++++++++ templates/testing.html | 5 +++ 13 files changed, 382 insertions(+) create mode 100644 .gitignore create mode 100644 main.py create mode 100644 static/css/main.css create mode 100644 static/images/logo.png create mode 100644 static/js/call.js create mode 100644 templates/admin.html create mode 100644 templates/default.html create mode 100644 templates/header.html create mode 100644 templates/index.html create mode 100644 templates/list.html create mode 100644 templates/otherpage.html create mode 100644 templates/sidebar.html create mode 100644 templates/testing.html 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 0000000000000000000000000000000000000000..51b1b608c8234f88b656e9589ba2eba8eb294eb4 GIT binary patch literal 2026 zcmVEX>4Tx04R}tkv&MmP!xqvTcsiuK`V%eWT;LSii$XD6^c+H)C#RSn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~9J6k5c1;qgAsyXWxUeSp7SW~$i{160j2 zQi-^b$*u~)SNJf30mRTJF;kxt#UwoI>z=x)?xH-)yYJ8HQF0~&d;;+-(+!JwgLrz= z(mC%Fhgnflh|h_~4Z0xlBiCh@-#8Z>_VdiJkxtDMhlzzk8_R9XiiS!&MI2F7jq?2& zmle)ioYiubHSft^7|LlY%Uq{5j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 zAy$1u3pa!W9KlxXjqqY%TZw=7Zmfp%RIK2g5E8HlElxONvc$Zli0ALZ3clC6bN4C) zM3O1xORSbGL5~6&vaGIv=lKD66WhRS9q^}`T?`h=(&==F*OkJyN6FZDEQ_ehSqeDR z^`Hl^X{DW5rHu}3amZ$OgXmN<3kg^V@xOlt7D7nCLI{Ar0Ms#qpW#{d8T07*qo IM6N<$g2Qi~_W%F@ literal 0 HcmV?d00001 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