File size: 2,661 Bytes
0017967
 
 
 
 
 
63477c4
0017967
 
 
 
 
 
 
 
 
 
 
63477c4
 
0017967
63477c4
0017967
 
63477c4
0017967
 
 
63477c4
0017967
 
63477c4
 
 
 
 
 
 
 
 
0017967
63477c4
0017967
 
63477c4
 
0017967
 
 
 
 
 
63477c4
0017967
 
63477c4
0017967
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/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()