From 58fe757a56d8e47a8ae1bb9ee743762e230cdaed Mon Sep 17 00:00:00 2001 From: Nikitat0 Date: Tue, 27 Feb 2024 13:38:37 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=B2=D1=81=D1=91=20=D0=BF=D0=BE=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=B9=D1=84=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- accounts.json | 6 + app.py | 35 ++++- data.json | 1 + .../__pycache__/__init__.cpython-311.pyc | Bin 156 -> 166 bytes .../__pycache__/esplistener.cpython-311.pyc | Bin 4037 -> 4048 bytes esplistener/esplistener.py | 2 +- index.bk | 139 ++++++++++++++++++ templates/accounts.json | 22 --- templates/index.html | 96 ++++++++---- templates/unauthorized.html | 97 +++++++++++- 10 files changed, 339 insertions(+), 59 deletions(-) create mode 100644 accounts.json create mode 100644 data.json create mode 100644 index.bk delete mode 100644 templates/accounts.json diff --git a/accounts.json b/accounts.json new file mode 100644 index 0000000..6b9b537 --- /dev/null +++ b/accounts.json @@ -0,0 +1,6 @@ +[ + { + "username": "1", + "password": "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b" + } +] \ No newline at end of file diff --git a/app.py b/app.py index 5c57096..123c0f2 100644 --- a/app.py +++ b/app.py @@ -70,13 +70,9 @@ def get_cur_speed(session): def index(): define_session(session) if session['loggedin'] == True: - cur_speed = 25 - if request.method == "POST": - cur_speed = request.form.get("slide") - return render_template("mashinka.html", cur_speed = cur_speed) - return render_template("mashinka.html", cur_speed = cur_speed) - else: return render_template("index.html") + else: + return render_template("unauthorized.html") @app.route('/register', methods = ["POST", "GET"]) def register(): @@ -109,25 +105,50 @@ def login(): else: return render_template("login.html", err="Неверный логин/пароль") -#Общение с ЕСП + + +#Общение с ЕSP + +@app.route("/get_data", methods = ["POST"]) +def return_data(): + if 1: +# if session['loggedin']: + sensors = ['earthquake', 'techka', 'pozhar', 'soundstatus', 'tok', 'potok', 'nasostoggle', 'nasosspeed','lightst', 'lightpower', 'gaz'] + data = {'1': {}, + '2': {}, + '3': {}} + for i in range(1,4): + for j in sensors: + if j in ['earthquake', 'techka', 'nasostoggle', 'pozhar', 'soundstatus', 'lighst', 'onfire', 'gaz']: + data[str(i)][j] = random.randint(0,1) + else: + data[str(i)][j] = random.randint(0, 100) + print(data) + return json.dumps(data) + return 'no_rights' + + @app.route("/sos_check", methods = ["POST"]) def sos_check(): if random.randint(0,1): return check_sos(socket) else: return '' + @app.route("/mashinka_go", methods = ["POST"]) def mashinka_go(): if session['loggedin']: return '' else: return "" + @app.route("/mashinka_stop", methods = ["POST"]) def mashinka_stop(): if session['loggedin']: return '' else: return "" + @app.route("/get_temperature", methods = ["POST"]) def get_temperature(): if session['loggedin']: diff --git a/data.json b/data.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/data.json @@ -0,0 +1 @@ +{} diff --git a/esplistener/__pycache__/__init__.cpython-311.pyc b/esplistener/__pycache__/__init__.cpython-311.pyc index 37e238b40a0e9e9aaaa59827602c74a1a0be2f9e..f2355b7f08e52cb51db199309282e4abe1afe347 100644 GIT binary patch delta 57 zcmbQkxQvl|IWI340}w=n-<`;9s${93k)NBYUznJeo|vbfSCVgJU}U0Snhv7UGV>C1 JiYG?6006}`5fuOc delta 47 zcmZ3+IERsYIWI340}#k9JTj5nR6<`rBR@A)zc4W`Juy$eB)336wYZ=>HECj!3ji@i B4xa!3 diff --git a/esplistener/__pycache__/esplistener.cpython-311.pyc b/esplistener/__pycache__/esplistener.cpython-311.pyc index 1a7cfa64d5c196d875b9e5e6fe36f6cd5832749e..daffbf8c115cd4bc7bc2b6463739a1dbba5afc5c 100644 GIT binary patch delta 96 zcmX>qe?gviIWI340}%X*zMFb;BkvwYK3+phBRxYi3q1opBNNNX*BFbHZ1gkob5r#T x6Z6s&^Yrsd@{J6PO!Q0BK~!31USdx19e)4- delta 85 zcmca0e^j1#IWI340}vQQpHIE9k#`RxFOQ+6k)ENMg`T0FvFYUNjKva0`WgATsrrS9 odFhFH`X#vq`l-bQ<*7-NbC|-o6fd$UU13qWz@oJI3=<1405?4v3IG5A diff --git a/esplistener/esplistener.py b/esplistener/esplistener.py index 0f354ae..6e4769f 100644 --- a/esplistener/esplistener.py +++ b/esplistener/esplistener.py @@ -7,7 +7,7 @@ gets_data = {} def initialize(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.bind(('192.168.1.35', 7777)) + s.bind(('192.168.0.249', 7777)) s.settimeout(0.5) with open('data.json') as f: data = json.load(f) diff --git a/index.bk b/index.bk new file mode 100644 index 0000000..4a4cb53 --- /dev/null +++ b/index.bk @@ -0,0 +1,139 @@ + + + + + + + Mashinka Control + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + diff --git a/templates/accounts.json b/templates/accounts.json deleted file mode 100644 index d7f0314..0000000 --- a/templates/accounts.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "username": "1", - "password": "d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35" - }, - { - "username": "1", - "password": "d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35" - }, - { - "username": "1", - "password": "4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce" - }, - { - "username": "2", - "password": "d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35" - }, - { - "username": "skillissue", - "password": "a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3" - } -] \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index bb8930b..4a4cb53 100644 --- a/templates/index.html +++ b/templates/index.html @@ -20,29 +20,85 @@
Seal Team - Недостаточно прав + Демонстрационный режим
-
-

Вы не авторизированы

-
- -       - -
+
+
- - + + + - diff --git a/templates/unauthorized.html b/templates/unauthorized.html index 2c9950c..dc98cb8 100644 --- a/templates/unauthorized.html +++ b/templates/unauthorized.html @@ -1,4 +1,99 @@ - no rights + + + + + Mashinka Control + + + + + + + + + + + + + +
+

Вы не авторизированы

+
+ +       + +
+ + + + + + + + + + + + + + + +