From 3eaaae52e625d013fe1e4965b4e7d07e2a9e5bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Tue, 4 Jan 2022 02:42:12 +0100 Subject: [PATCH] fixxed code block oder of the api --- main.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index b452a65..9315f28 100644 --- a/main.py +++ b/main.py @@ -11,20 +11,6 @@ except: from flask import Flask, request 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_COUNT = 60 # Number of LED pixels. LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!). @@ -86,6 +72,19 @@ def power_toggle(channel): global power_button_pressed 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__': threading.Thread(target=lambda: app.run(host="0.0.0.0", port=80, debug=True, use_reloader=False)).start() led_power = 'True'