fixxed code block oder of the api
parent
ee5d2fd3be
commit
3eaaae52e6
27
main.py
27
main.py
|
@ -11,20 +11,6 @@ except:
|
||||||
from flask import Flask, request
|
from flask import Flask, request
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
#Web API
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
@app.route('/')
|
|
||||||
def index():
|
|
||||||
command = str(request.args.get('command'))
|
|
||||||
if command == "switch-ilde-mode":
|
|
||||||
change_idle_mode
|
|
||||||
elif command == "switch-toggle-on-off":
|
|
||||||
power_toggle
|
|
||||||
|
|
||||||
return command
|
|
||||||
|
|
||||||
|
|
||||||
# LED strip configuration:
|
# LED strip configuration:
|
||||||
LED_COUNT = 60 # Number of LED pixels.
|
LED_COUNT = 60 # Number of LED pixels.
|
||||||
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
|
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
|
||||||
|
@ -86,6 +72,19 @@ def power_toggle(channel):
|
||||||
global power_button_pressed
|
global power_button_pressed
|
||||||
power_button_pressed = 'True'
|
power_button_pressed = 'True'
|
||||||
|
|
||||||
|
#Web API
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
command = str(request.args.get('command'))
|
||||||
|
if command == "switch-ilde-mode":
|
||||||
|
change_idle_mode
|
||||||
|
elif command == "switch-toggle-on-off":
|
||||||
|
power_toggle
|
||||||
|
|
||||||
|
return command
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
threading.Thread(target=lambda: app.run(host="0.0.0.0", port=80, debug=True, use_reloader=False)).start()
|
threading.Thread(target=lambda: app.run(host="0.0.0.0", port=80, debug=True, use_reloader=False)).start()
|
||||||
led_power = 'True'
|
led_power = 'True'
|
||||||
|
|
Loading…
Reference in New Issue