first commit

This commit is contained in:
Michael Clemens 2019-10-29 22:13:45 +00:00
commit 8c4787da15
3 changed files with 62 additions and 0 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
# DX70CAT

42
dx70cat.py Normal file
View File

@ -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')

19
templates/index.html Normal file
View File

@ -0,0 +1,19 @@
<html>
<head>
<title>DX70CAT</title>
</head>
<body>
<form action = "/index" method = "post">
<table>
<tr>
<td><button type ="submit" name="ant_button" style="background-color:#eeeeee;color:black;width:200px;height:40px;" value="up">up</button></td>
</tr>
<tr>
<td><button type ="submit" name="ant_button" style="background-color:#eeeeee;color:black;width:200px;height:40px;" value="down">down</button></td>
</tr>
<tr>
<td><div style="text-align: left;"> <img id="mjpgImage" alt="Processing..." src="http://192.168.88.40/video/mjpg.cgi" > </img> </div></td>
</tr>
</form>
</body>
</html>