From b7cc3d1b71529ed87b3d2f1a00ad57e434fdbfb1 Mon Sep 17 00:00:00 2001 From: rav4s Date: Fri, 18 Dec 2020 10:41:56 -0600 Subject: [PATCH] Added garage open/close button --- garage_door_script.py | 4 +++- templates/index.html | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/garage_door_script.py b/garage_door_script.py index b9cadbe..2c81248 100644 --- a/garage_door_script.py +++ b/garage_door_script.py @@ -40,11 +40,13 @@ def index(): distance = round(pulse_duration * 17150, 2) #Convert the time it took to centimeters and round to 2 decimals if distance >= 80: #Check if the distance is less than 80cm (This will depend on the garage) message = 'The garage is closed.' + OpenOrClose = 'Open' else: message = 'The garage is open.' + OpenOrClose = 'Close' else: return redirect(url_for('login')) - return render_template('index.html', message=message, distance=distance) + return render_template('index.html', message=message, distance=distance, OpenOrClose=OpenOrClose) # Route for the login page @app.route('/login', methods=['GET', 'POST']) diff --git a/templates/index.html b/templates/index.html index 7a50f10..816b6bb 100644 --- a/templates/index.html +++ b/templates/index.html @@ -13,12 +13,13 @@
-
+

{{ message }}

The current sensor distance is {{ distance }} centimeters.

-
-

Hello

+
+

Trigger the garage door opener.

+ {{ OpenOrClose }}