Browse Source

Added garage open/close button

pull/1/head
Ravi Shah 5 years ago
parent
commit
b7cc3d1b71
  1. 4
      garage_door_script.py
  2. 7
      templates/index.html

4
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'])

7
templates/index.html

@ -13,12 +13,13 @@
</div>
</div>
<div class="row">
<div class="column" style="background-color:#aaa">
<div class="column" style="background-color:#ccc">
<p style="font-size:20px;">{{ message }}</p>
<p style="font-size:20px;">The current sensor distance is {{ distance }} centimeters.</p>
</div>
<div class="column" style="background-color:#bbb">
<p>Hello</p>
<div class="column" style="background-color:#ddd">
<p style="font-size:20px;">Trigger the garage door opener.</p>
<a class="active" href="/open-garage">{{ OpenOrClose }}</a>
</div>
</div>
</body>

Loading…
Cancel
Save