IAGO / app.py
James Frecheville
Update dependencies and add browser installation handling
e7f6bbd
raw
history blame
1.14 kB
import os
import sys
from pathlib import Path
# Add current directory to Python path
current_dir = Path(__file__).parent.absolute()
if str(current_dir) not in sys.path:
sys.path.append(str(current_dir))
# Configure Gradio environment
os.environ["GRADIO_ANALYTICS_ENABLED"] = "false"
os.environ["GRADIO_SERVER_NAME"] = "0.0.0.0"
os.environ["GRADIO_SERVER_PORT"] = "7861"
os.environ["GRADIO_ALLOW_FLAGGING"] = "false"
os.environ["GRADIO_QUEUE_ENABLED"] = "false"
# Install browser dependencies if needed
try:
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
p.chromium.launch()
except Exception as e:
print(f"Browser installation error: {e}")
print("Attempting to install browser...")
import subprocess
subprocess.run(["playwright", "install", "chromium"], check=True)
from owl.webapp import create_ui
# Create Gradio interface
demo = create_ui()
# Launch the app
if __name__ == "__main__":
demo.launch(
server_name="0.0.0.0",
server_port=7861,
share=False,
show_error=True,
favicon_path=None,
allowed_paths=None
)