OSINT-suite / run_app.py
Ba7ath-Project's picture
Ba7ath Deployment
d8b87e0
Raw History Blame Contribute Delete
1.48 kB
import os
import sys
import webbrowser
import threading
import time
import multiprocessing
import config
# Charger les clés API dans l'environnement virtuel en toute sécurité
config.load_keys()
def start_streamlit():
# Import streamlit inside the function to ensure freeze_support is called first
import streamlit.web.cli as stcli
os.environ["STREAMLIT_SERVER_HEADLESS"] = "true"
os.environ["STREAMLIT_SERVER_PORT"] = "8501"
os.environ["STREAMLIT_SERVER_FILE_WATCHER_TYPE"] = "none"
os.environ["STREAMLIT_GLOBAL_DISABLE_WATCHDOG"] = "true"
os.environ["STREAMLIT_BROWSER_GATHER_USAGE_STATS"] = "false"
if getattr(sys, 'frozen', False):
base_dir = sys._MEIPASS
else:
base_dir = os.path.dirname(os.path.abspath(__file__))
dashboard_path = os.path.join(base_dir, 'dashboard.py')
sys.argv = ["streamlit", "run", dashboard_path, "--global.developmentMode=false"]
# Exécuter streamlit
sys.exit(stcli.main())
def open_browser():
time.sleep(3) # Attendre 3 secondes que le serveur Streamlit démarre
webbrowser.open("http://localhost:8501")
if __name__ == "__main__":
# Indispensable pour PyInstaller sur Windows avec certains packages (ex: playwright)
multiprocessing.freeze_support()
# Ouvrir le navigateur dans un thread séparé
threading.Thread(target=open_browser, daemon=True).start()
# Démarrer le serveur Streamlit
start_streamlit()