#!/usr/bin/env python3
"""
Startup script for the SVG Wireframe Generator Backend
"""

import os
from dotenv import load_dotenv
from app import app

if __name__ == '__main__':
    # Load environment variables
    load_dotenv()
    
    # Get configuration
    port = int(os.environ.get('PORT', 5000))
    debug = os.environ.get('FLASK_DEBUG', 'True').lower() == 'true'
    
    print("🚀 Starting SVG Wireframe Generator Backend...")
    print(f"📍 Port: {port}")
    print(f"🔧 Debug: {debug}")
    print(f"🌐 URL: http://localhost:{port}")
    print("=" * 50)
    
    try:
        app.run(
            debug=debug,
            host='0.0.0.0',
            port=port,
            use_reloader=debug
        )
    except KeyboardInterrupt:
        print("\n🛑 Server stopped by user")
    except Exception as e:
        print(f"❌ Error starting server: {e}")
        exit(1)
