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 37e238b..f2355b7 100644 Binary files a/esplistener/__pycache__/__init__.cpython-311.pyc and b/esplistener/__pycache__/__init__.cpython-311.pyc differ diff --git a/esplistener/__pycache__/esplistener.cpython-311.pyc b/esplistener/__pycache__/esplistener.cpython-311.pyc index 1a7cfa6..daffbf8 100644 Binary files a/esplistener/__pycache__/esplistener.cpython-311.pyc and b/esplistener/__pycache__/esplistener.cpython-311.pyc differ 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 + + + + + + + + + + + + + +
+

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

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