Spaces:
Sleeping
Sleeping
| """ | |
| PhishingInsight - Enterprise Phishing Detection System | |
| """ | |
| import sys | |
| import os | |
| import uvicorn | |
| import threading | |
| import logging | |
| # Ensure src module is visible | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| # Configure Logging to Console | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | |
| handlers=[logging.StreamHandler(sys.stdout)] | |
| ) | |
| from src.interface.ui import app as ui_app, app_theme, custom_css | |
| from src.interface.api import app as api_app | |
| from src.ml import slm_explainer | |
| if __name__ == "__main__": | |
| print("\n" + "=" * 60) | |
| print(" PhishingInsight Security Suite") | |
| print(" Booting System Modules...") | |
| print("=" * 60) | |
| # Preload SLM Model (this can take a moment) | |
| print("\n[+] Initializing Core Engines...") | |
| slm_explainer.load_model() | |
| print("[✓] AI Engines Ready") | |
| def run_api(): | |
| """Run REST API on Port 8000""" | |
| print("[*] Starting REST API -> http://0.0.0.0:8000") | |
| uvicorn.run(api_app, host="0.0.0.0", port=8000, log_level="error") | |
| def run_ui(): | |
| """Run Web UI on Port 7860""" | |
| print("[*] Starting Web UI -> http://0.0.0.0:7860") | |
| # prevent_thread_lock=True is default logic for launch() in scripts | |
| ui_app.launch( | |
| server_name="0.0.0.0", | |
| server_port=7860, | |
| prevent_thread_lock=False, | |
| theme=app_theme, | |
| css=custom_css, | |
| quiet=True | |
| ) | |
| # Launch Services | |
| print("\n[+] Launching Interfaces...") | |
| # 3. Start API in separate thread | |
| api_thread = threading.Thread(target=run_api, daemon=True) | |
| api_thread.start() | |
| # 4. Start UI in main thread | |
| try: | |
| run_ui() | |
| except KeyboardInterrupt: | |
| print("\n[!] Shutting down system...") | |