diff --git a/thermostat.py b/thermostat.py index ff3cfe2..44f883e 100644 --- a/thermostat.py +++ b/thermostat.py @@ -195,11 +195,11 @@ class Set_mode_thermostat(Resource): return "K0", 400 try: db.session.add(data) - except sqlite3.IntegrityError: - logging.error("catched") - try: db.session.commit() return "OK", 201 + except sqlite3.IntegrityError: + logging.error("catched") + return "K0", 400 except Exception as e: logging.error(e) return "K0", 400