Browse Source

More cookie stuff

pull/1/head
Ravi Shah 5 years ago
parent
commit
89800feba1
  1. 4
      garage_door_script.py

4
garage_door_script.py

@ -22,6 +22,8 @@ correct_login = 0
# Route for the main page # Route for the main page
@app.route('/') @app.route('/')
def index(): def index():
logged_in = request.cookies.get('logged_in')
if logged_in == "yes":
GPIO.setup(PIN_TRIG, GPIO.OUT) #Setup the gpio trigger pin as input GPIO.setup(PIN_TRIG, GPIO.OUT) #Setup the gpio trigger pin as input
GPIO.setup(PIN_ECHO, GPIO.IN) #Setup the gpio echo pin as output GPIO.setup(PIN_ECHO, GPIO.IN) #Setup the gpio echo pin as output
time.sleep(2) #Wait for 2 seconds for sensor to settle time.sleep(2) #Wait for 2 seconds for sensor to settle
@ -39,6 +41,8 @@ def index():
return 'The garage is closed.' return 'The garage is closed.'
else: else:
return 'The garage is open.' return 'The garage is open.'
else:
return 'Please login.'
# Route for the login page # Route for the login page
@app.route('/login', methods=['GET', 'POST']) @app.route('/login', methods=['GET', 'POST'])

Loading…
Cancel
Save