code cleanup
This commit is contained in:
parent
b89488f602
commit
4558b9d6f4
10
antennapi.py
10
antennapi.py
|
@ -10,12 +10,10 @@ 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')
|
||||
|
@ -25,21 +23,15 @@ def index():
|
|||
if request.method == 'POST':
|
||||
if request.form['ant_button'] == 'Antenna 1':
|
||||
GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
GPIO.output(RELAIS_1_GPIO, GPIO.LOW)
|
||||
print('Antenna 1 selected')
|
||||
return redirect(url_for('start'))
|
||||
if request.form['ant_button'] == 'Antenna 2':
|
||||
GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
GPIO.output(RELAIS_2_GPIO, GPIO.LOW)
|
||||
print('Antenna 2 selected')
|
||||
return redirect(url_for('start'))
|
||||
if request.form['ant_button'] == 'Antenna 3':
|
||||
GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
|
||||
time.sleep(1)
|
||||
GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
|
||||
print('Antenna 2 selected')
|
||||
return redirect(url_for('start'))
|
||||
else:
|
||||
print(request.form.action)
|
||||
|
|
Loading…
Reference in New Issue