Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ Luminet - Hugging Face Spaces Entry Point
|
|
| 4 |
==========================================
|
| 5 |
|
| 6 |
This file serves as the entry point for Hugging Face Spaces deployment.
|
| 7 |
-
It
|
| 8 |
"""
|
| 9 |
|
| 10 |
import subprocess
|
|
@@ -16,39 +16,44 @@ def install_system_dependencies():
|
|
| 16 |
try:
|
| 17 |
print("📦 Installing system dependencies...")
|
| 18 |
|
| 19 |
-
# Update package list
|
| 20 |
-
subprocess.run(["apt-get", "update"], check=
|
| 21 |
|
| 22 |
-
# Install required packages (
|
| 23 |
packages = [
|
| 24 |
"traceroute", # Network path tracing
|
|
|
|
| 25 |
"dnsutils", # DNS utilities
|
| 26 |
"iputils-ping", # Ping utility
|
| 27 |
"curl", # HTTP client for health checks
|
| 28 |
-
"
|
| 29 |
]
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
print("✅ System
|
| 35 |
-
print("⚠️ Note: Some advanced features (port scanning) may not be available without root privileges.")
|
| 36 |
|
| 37 |
-
except subprocess.CalledProcessError as e:
|
| 38 |
-
print(f"❌ Failed to install system dependencies: {e}")
|
| 39 |
-
print("⚠️ Some features may not work properly without these tools.")
|
| 40 |
except Exception as e:
|
| 41 |
-
print(f"❌
|
|
|
|
| 42 |
|
| 43 |
def main():
|
| 44 |
"""Main entry point for Hugging Face Spaces."""
|
| 45 |
print("🌐 Starting Luminet - Network Analysis Tool")
|
| 46 |
print("=" * 50)
|
| 47 |
|
| 48 |
-
#
|
| 49 |
install_system_dependencies()
|
| 50 |
|
| 51 |
-
# Set environment variables for Hugging Face
|
| 52 |
os.environ.setdefault("PORT", "7860")
|
| 53 |
os.environ.setdefault("SECRET_KEY", "luminet-hf-spaces-2024")
|
| 54 |
|
|
|
|
| 4 |
==========================================
|
| 5 |
|
| 6 |
This file serves as the entry point for Hugging Face Spaces deployment.
|
| 7 |
+
It ensures compatibility with the Spaces environment and starts the Flask application.
|
| 8 |
"""
|
| 9 |
|
| 10 |
import subprocess
|
|
|
|
| 16 |
try:
|
| 17 |
print("📦 Installing system dependencies...")
|
| 18 |
|
| 19 |
+
# Update package list (non-interactive)
|
| 20 |
+
subprocess.run(["apt-get", "update"], check=False, capture_output=True)
|
| 21 |
|
| 22 |
+
# Install required packages (skip if already installed)
|
| 23 |
packages = [
|
| 24 |
"traceroute", # Network path tracing
|
| 25 |
+
"nmap", # Port scanning
|
| 26 |
"dnsutils", # DNS utilities
|
| 27 |
"iputils-ping", # Ping utility
|
| 28 |
"curl", # HTTP client for health checks
|
| 29 |
+
"mtr", # Network diagnostics
|
| 30 |
]
|
| 31 |
|
| 32 |
+
for package in packages:
|
| 33 |
+
try:
|
| 34 |
+
result = subprocess.run(["which", package], capture_output=True)
|
| 35 |
+
if result.returncode == 0:
|
| 36 |
+
print(f"✅ {package} already available")
|
| 37 |
+
else:
|
| 38 |
+
print(f"⚠️ {package} not found, functionality may be limited")
|
| 39 |
+
except Exception:
|
| 40 |
+
pass
|
| 41 |
|
| 42 |
+
print("✅ System dependency check completed!")
|
|
|
|
| 43 |
|
|
|
|
|
|
|
|
|
|
| 44 |
except Exception as e:
|
| 45 |
+
print(f"❌ Error during system setup: {e}")
|
| 46 |
+
print("⚠️ Some features may not work properly without these tools.")
|
| 47 |
|
| 48 |
def main():
|
| 49 |
"""Main entry point for Hugging Face Spaces."""
|
| 50 |
print("🌐 Starting Luminet - Network Analysis Tool")
|
| 51 |
print("=" * 50)
|
| 52 |
|
| 53 |
+
# Check system dependencies (non-blocking)
|
| 54 |
install_system_dependencies()
|
| 55 |
|
| 56 |
+
# Set environment variables for Hugging Face Spaces
|
| 57 |
os.environ.setdefault("PORT", "7860")
|
| 58 |
os.environ.setdefault("SECRET_KEY", "luminet-hf-spaces-2024")
|
| 59 |
|