From 8c4787da15dd16bae52b3f6792ca3f27c7116551 Mon Sep 17 00:00:00 2001 From: Michael Clemens Date: Tue, 29 Oct 2019 22:13:45 +0000 Subject: [PATCH] first commit --- README.md | 1 + dx70cat.py | 42 ++++++++++++++++++++++++++++++++++++++++++ templates/index.html | 19 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 README.md create mode 100644 dx70cat.py create mode 100644 templates/index.html diff --git a/README.md b/README.md new file mode 100644 index 0000000..150cb72 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# DX70CAT diff --git a/dx70cat.py b/dx70cat.py new file mode 100644 index 0000000..54eb12d --- /dev/null +++ b/dx70cat.py @@ -0,0 +1,42 @@ +from flask import Flask, redirect, url_for, request, render_template +import RPi.GPIO as GPIO +import sys +import time + +app = Flask(__name__) + +GPIO.setmode(GPIO.BCM) +GPIO.setwarnings(False) + +RELAIS_1_GPIO = 0 +RELAIS_2_GPIO = 1 + +GPIO.setup(RELAIS_1_GPIO, GPIO.OUT) +GPIO.setup(RELAIS_2_GPIO, GPIO.OUT) + +GPIO.output(RELAIS_1_GPIO, GPIO.HIGH) +GPIO.output(RELAIS_2_GPIO, GPIO.HIGH) + +@app.route('/') +def start(): + return render_template('index.html') + +@app.route('/index',methods = ['POST', 'GET']) +def index(): + if request.method == 'POST': + if request.form['ant_button'] == 'up': + GPIO.output(RELAIS_2_GPIO, GPIO.LOW) + time.sleep(.100) + GPIO.output(RELAIS_2_GPIO, GPIO.HIGH) + return redirect(url_for('start')) + if request.form['ant_button'] == 'down': + GPIO.output(RELAIS_1_GPIO, GPIO.LOW) + time.sleep(.100) + GPIO.output(RELAIS_1_GPIO, GPIO.HIGH) + return redirect(url_for('start')) + else: + print(request.form.action) + return redirect(url_for('start')) + +if __name__ == '__main__': + app.run(host='0.0.0.0', port='5000') diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..1959641 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,19 @@ + + + DX70CAT + + +
+ + + + + + + + + + + + +
Processing...