fagun18 commited on
Commit
e95fa56
·
verified ·
1 Parent(s): 8cf9a0d

Add automatic Playwright browser installation on startup

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -38,6 +38,30 @@ logging.getLogger("posthog").setLevel(logging.WARNING)
38
  from dotenv import load_dotenv
39
  load_dotenv()
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  from src.webui.interface import create_ui
42
 
43
  # Create the Gradio interface
 
38
  from dotenv import load_dotenv
39
  load_dotenv()
40
 
41
+ # Install Playwright browsers on first run
42
+ import subprocess
43
+ import sys
44
+
45
+ def install_playwright_browsers():
46
+ """Install Playwright browsers if not already installed"""
47
+ try:
48
+ print("🔍 Checking Playwright browsers...")
49
+ result = subprocess.run(
50
+ [sys.executable, "-m", "playwright", "install", "chromium", "firefox"],
51
+ capture_output=True,
52
+ text=True,
53
+ timeout=300
54
+ )
55
+ if result.returncode == 0:
56
+ print("✅ Playwright browsers installed successfully")
57
+ else:
58
+ print(f"⚠️ Playwright install warning: {result.stderr}")
59
+ except Exception as e:
60
+ print(f"⚠️ Could not install Playwright browsers: {e}")
61
+
62
+ # Install browsers on startup
63
+ install_playwright_browsers()
64
+
65
  from src.webui.interface import create_ui
66
 
67
  # Create the Gradio interface