From c97c099259378216956914e791b20050b727c639 Mon Sep 17 00:00:00 2001
From: akdag <cem.akdag@student.reutlingen-university.de>
Date: Tue, 29 Jun 2021 10:54:13 +0200
Subject: [PATCH] app.py lamp api updated

---
 backend/app.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/backend/app.py b/backend/app.py
index 6bc4c1a..b93f88e 100644
--- a/backend/app.py
+++ b/backend/app.py
@@ -46,12 +46,13 @@ def create_app(test_config=None):
             abort(404)
 
         try:
+            GPIO.setmode(GPIO.BOARD)
         
             if lamp_id == 1:
                 # Leuchte 1 für Reaktion "Frage" (BLAU)
                 
                 # set GPIO pins, requesting pins bei the board numbers (1-40)
-                GPIO.setmode(GPIO.BOARD)
+                #GPIO.setmode(GPIO.BOARD)
                 GPIO.setup(11,GPIO.OUT)
                 GPIO.output(11,GPIO.LOW)
 
@@ -61,13 +62,13 @@ def create_app(test_config=None):
 
                 # deactivate GPIO pins
                 GPIO.output(11,GPIO.LOW)
-                GPIO.cleanup()
+               
 
             if lamp_id == 2:
                 # Leuchte 2 für Reaktion "Daumen hoch" (GRÜN)
 
                 # set GPIO pins, requesting pins bei the board numbers (1-40)
-                GPIO.setmode(GPIO.BOARD)
+                #GPIO.setmode(GPIO.BOARD)
                 GPIO.setup(13,GPIO.OUT)
                 GPIO.output(13,GPIO.LOW)
 
@@ -77,13 +78,13 @@ def create_app(test_config=None):
 
                 # deactivate GPIO pins
                 GPIO.output(13,GPIO.LOW)
-                GPIO.cleanup()
+                
 
             if lamp_id == 3:
                 # Leuchte 3 für Reaktion "Problem" (ROT)
 
                 # set GPIO pins, requesting pins bei the board numbers (1-40)
-                GPIO.setmode(GPIO.BOARD)
+                #GPIO.setmode(GPIO.BOARD)
                 GPIO.setup(15,GPIO.OUT)
                 GPIO.output(15,GPIO.LOW)
 
@@ -93,7 +94,8 @@ def create_app(test_config=None):
 
                 # deactivate GPIO pins
                 GPIO.output(15,GPIO.LOW)
-                GPIO.cleanup()
+                
+            GPIO.cleanup()
 
             return jsonify({
                 'lamp_id': lamp_id,
-- 
GitLab