#!/usr/bin/env python3 """ Luminet - Hugging Face Spaces Entry Point ========================================== This file serves as the entry point for Hugging Face Spaces deployment. It ensures compatibility with the Spaces environment and starts the Flask application. """ import subprocess import sys import os def install_system_dependencies(): """Install required system packages for network analysis tools.""" try: print("📦 Installing system dependencies...") # Update package list (non-interactive) subprocess.run(["apt-get", "update"], check=False, capture_output=True) # Install required packages (skip if already installed) packages = [ "traceroute", # Network path tracing "nmap", # Port scanning "dnsutils", # DNS utilities "iputils-ping", # Ping utility "curl", # HTTP client for health checks "mtr", # Network diagnostics ] for package in packages: try: result = subprocess.run(["which", package], capture_output=True) if result.returncode == 0: print(f"✅ {package} already available") else: print(f"⚠️ {package} not found, functionality may be limited") except Exception: pass print("✅ System dependency check completed!") except Exception as e: print(f"❌ Error during system setup: {e}") print("⚠️ Some features may not work properly without these tools.") def main(): """Main entry point for Hugging Face Spaces.""" print("🌐 Starting Luminet - Network Analysis Tool") print("=" * 50) # Check system dependencies (non-blocking) install_system_dependencies() # Set environment variables for Hugging Face Spaces os.environ.setdefault("PORT", "7860") os.environ.setdefault("SECRET_KEY", "luminet-hf-spaces-2024") print("🚀 Launching Flask application...") # Import and run the main Flask app try: from main import app # Run the application app.run( host="0.0.0.0", port=int(os.environ.get("PORT", 7860)), debug=False, threaded=True ) except ImportError as e: print(f"❌ Failed to import main application: {e}") sys.exit(1) except Exception as e: print(f"❌ Failed to start application: {e}") sys.exit(1) if __name__ == "__main__": main()