diff --git a/klaxon_flask.py b/klaxon_flask.py index 8ee726a..09cfdfe 100755 --- a/klaxon_flask.py +++ b/klaxon_flask.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from flask import Flask, render_template, request +from flask import Flask, render_template from paste.translogger import TransLogger import RPi.GPIO as GPIO from waitress import serve @@ -10,11 +10,8 @@ app = Flask(__name__) def setup(): - print('Running setup') GPIO.setmode(GPIO.BCM) GPIO.setup(RELAIS_1_GPIO, GPIO.OUT) - GPIO.output(RELAIS_1_GPIO, GPIO.HIGH) # Defaulting to high/off - print('GPIO setup, pin set to off') @app.route('/') @@ -24,16 +21,14 @@ def home(): @app.route('/start') def starthorn(): - GPIO.setmode(GPIO.BCM) - GPIO.setup(RELAIS_1_GPIO, GPIO.OUT) + setup() GPIO.output(RELAIS_1_GPIO, GPIO.LOW) # Toggle switch to low/on return('Sending power to the relay switch, hopefully toggling a horn...') @app.route('/stop') def stophorn(): - GPIO.setmode(GPIO.BCM) - GPIO.setup(RELAIS_1_GPIO, GPIO.OUT) + setup() GPIO.output(RELAIS_1_GPIO, GPIO.HIGH) # Toggle switch to high/off GPIO.cleanup() return('Ceasing power to the relay switch, hopefully silencing a horn...') @@ -46,7 +41,10 @@ def destroy(): if __name__ == '__main__': # Program entrance try: + print('Running setup') setup() + GPIO.output(RELAIS_1_GPIO, GPIO.HIGH) # Defaulting to high/off + print('GPIO setup, pin set to off') serve(TransLogger(app, setup_console_handler=False), listen='*:5000') finally: destroy() diff --git a/templates/index.html b/templates/index.html index e77ed76..d742394 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,7 +1,7 @@ - + Klaxon horn jump scare button @@ -10,13 +10,16 @@
-
+
+

+ Klaxon Horn Jump Scare Control +

-