Spaces:
Sleeping
Sleeping
update
Browse files- app/server.py +15 -15
app/server.py
CHANGED
@@ -5,6 +5,7 @@ from fastapi.responses import HTMLResponse, JSONResponse, FileResponse
|
|
5 |
from fastapi.staticfiles import StaticFiles
|
6 |
from fastapi.templating import Jinja2Templates
|
7 |
from helium import start_chrome, kill_browser, get_driver
|
|
|
8 |
import uuid
|
9 |
import logging
|
10 |
import pathlib
|
@@ -50,24 +51,23 @@ async def take_screenshot(url: str = Form(...)):
|
|
50 |
logger.info(f"HOME env: {os.environ.get('HOME')}")
|
51 |
logger.info(f"Current working directory: {os.getcwd()}")
|
52 |
|
53 |
-
# Configuration
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
]
|
66 |
-
}
|
67 |
|
68 |
# Take the screenshot with Helium
|
69 |
logger.info("Launching Chrome browser")
|
70 |
-
|
|
|
71 |
|
72 |
logger.info("Browser launched successfully")
|
73 |
|
|
|
5 |
from fastapi.staticfiles import StaticFiles
|
6 |
from fastapi.templating import Jinja2Templates
|
7 |
from helium import start_chrome, kill_browser, get_driver
|
8 |
+
from selenium import webdriver
|
9 |
import uuid
|
10 |
import logging
|
11 |
import pathlib
|
|
|
51 |
logger.info(f"HOME env: {os.environ.get('HOME')}")
|
52 |
logger.info(f"Current working directory: {os.getcwd()}")
|
53 |
|
54 |
+
# Configuration pour Chrome dans Helium
|
55 |
+
# Créer les options Chrome à la manière Selenium
|
56 |
+
chrome_options = webdriver.ChromeOptions()
|
57 |
+
chrome_options.add_argument('--headless')
|
58 |
+
chrome_options.add_argument('--no-sandbox')
|
59 |
+
chrome_options.add_argument('--disable-setuid-sandbox')
|
60 |
+
chrome_options.add_argument('--disable-dev-shm-usage')
|
61 |
+
chrome_options.add_argument('--disable-accelerated-2d-canvas')
|
62 |
+
chrome_options.add_argument('--no-first-run')
|
63 |
+
chrome_options.add_argument('--no-zygote')
|
64 |
+
chrome_options.add_argument('--single-process')
|
65 |
+
chrome_options.add_argument('--disable-gpu')
|
|
|
|
|
66 |
|
67 |
# Take the screenshot with Helium
|
68 |
logger.info("Launching Chrome browser")
|
69 |
+
# Utiliser les options Chrome configurées pour Selenium
|
70 |
+
driver = start_chrome(url, headless=True, options=chrome_options)
|
71 |
|
72 |
logger.info("Browser launched successfully")
|
73 |
|