|
|
|
|
|
""" |
|
|
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...") |
|
|
|
|
|
|
|
|
subprocess.run(["apt-get", "update"], check=False, capture_output=True) |
|
|
|
|
|
|
|
|
packages = [ |
|
|
"traceroute", |
|
|
"nmap", |
|
|
"dnsutils", |
|
|
"iputils-ping", |
|
|
"curl", |
|
|
"mtr", |
|
|
] |
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
install_system_dependencies() |
|
|
|
|
|
|
|
|
os.environ.setdefault("PORT", "7860") |
|
|
os.environ.setdefault("SECRET_KEY", "luminet-hf-spaces-2024") |
|
|
|
|
|
print("🚀 Launching Flask application...") |
|
|
|
|
|
|
|
|
try: |
|
|
from main import app |
|
|
|
|
|
|
|
|
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() |