diff --git a/app.py b/app.py index b955f02..620ba26 100644 --- a/app.py +++ b/app.py @@ -23,16 +23,13 @@ def api_root(): @app.route('/device//', methods=["GET", "POST"]) def api_leds_control(device_name): - if request.method == "POST": - # if color in LEDS: - # GPIO.output(LEDS[color], int(request.data.get("state"))) - try: + try: + if request.method == "POST": response = interface_handler.write(device_name,request.data.get("output")) return {'output': response} - except Exception as e: - return {'error': str(e)} - # return {color: GPIO.input(LEDS[color])} - return {'state': interface_handler.read(device_name)} + return {'state': interface_handler.read(device_name)} + except Exception as e: + return {'error': str(e)} if __name__ == "__main__": app.run(port=8080,host="0.0.0.0")