diff --git a/Machine-Backend/app/__init__.py b/Machine-Backend/app/__init__.py index fd09701..6eb81b8 100644 --- a/Machine-Backend/app/__init__.py +++ b/Machine-Backend/app/__init__.py @@ -65,16 +65,20 @@ def create_app(): db.create_all() print(f"✓ Database initialized ({flask_env})") - # FIXED: Serial service connection BEFORE return - from app.services.services import serial_service - try: - connected = serial_service.connect_to_machine('/dev/ttyUSB0', 9600) - if connected: - print("✓ Vending machine connected successfully") - else: - print("✗ Failed to connect to vending machine") - except Exception as e: - print(f"⚠ Serial connection error: {e}") + # OPTIONAL: Serial service connection (non-blocking) + # Only attempt connection if ENABLE_SERIAL is set to true + if os.getenv('ENABLE_SERIAL', 'false').lower() == 'true': + from app.services.services import serial_service + try: + connected = serial_service.connect_to_machine('/dev/ttyUSB0', 9600) + if connected: + print("✓ Vending machine connected successfully") + else: + print("⚠ Vending machine not connected (device may not be available)") + except Exception as e: + print(f"⚠ Serial connection skipped: {e}") + else: + print("ℹ Serial connection disabled (set ENABLE_SERIAL=true to enable)") # Register blueprints from app.routes.routes import bp diff --git a/Machine-Backend/requirements.txt b/Machine-Backend/requirements.txt index 43101f1..e6b766f 100644 --- a/Machine-Backend/requirements.txt +++ b/Machine-Backend/requirements.txt @@ -5,4 +5,5 @@ python-dotenv pymysql gunicorn cryptography -pyserial \ No newline at end of file +pyserial +PyJWT \ No newline at end of file