Update app.py
Browse files
app.py
CHANGED
|
@@ -22,16 +22,20 @@ if not IS_HF:
|
|
| 22 |
return args[0]
|
| 23 |
return decorator
|
| 24 |
else:
|
| 25 |
-
import os
|
| 26 |
os.environ['SUPERTONIC_CACHE_DIR'] = '/home/user/huggingface'
|
| 27 |
os.environ["HF_HOME"] = "/home/user/huggingface"
|
| 28 |
os.environ['XDG_CACHE_HOME'] = "/home/user/huggingface"
|
| 29 |
-
|
| 30 |
-
os.environ['PLAYWRIGHT_BROWSERS_PATH'] = "/home/user/huggingface/ms-playwright"
|
| 31 |
|
| 32 |
-
os.
|
| 33 |
-
os.system("
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
import gradio as gr
|
| 37 |
import fitz # PyMuPDF
|
|
@@ -86,7 +90,6 @@ def extract_website_content(url, max_images=2):
|
|
| 86 |
browser.close()
|
| 87 |
except Exception as e:
|
| 88 |
print(f"Playwright headless fetch failed: {e}. Falling back to requests...")
|
| 89 |
-
os.system("ls -R /home/user/huggingface/ms-playwright/chromium_headless_shell-1223")
|
| 90 |
response = requests.get(url, headers=headers, timeout=10)
|
| 91 |
response.raise_for_status()
|
| 92 |
html_content = response.content
|
|
|
|
| 22 |
return args[0]
|
| 23 |
return decorator
|
| 24 |
else:
|
| 25 |
+
import os, sys, subprocess
|
| 26 |
os.environ['SUPERTONIC_CACHE_DIR'] = '/home/user/huggingface'
|
| 27 |
os.environ["HF_HOME"] = "/home/user/huggingface"
|
| 28 |
os.environ['XDG_CACHE_HOME'] = "/home/user/huggingface"
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
os.environ['PLAYWRIGHT_BROWSERS_PATH'] = "/home/user/huggingface/ms-playwright"
|
| 31 |
+
# os.system("playwright install chromium")
|
| 32 |
+
result = subprocess.run(
|
| 33 |
+
[sys.executable, "-m", "playwright", "install", "chromium"],
|
| 34 |
+
env={**os.environ},
|
| 35 |
+
check=True,
|
| 36 |
+
stdout=subprocess.PIPE,
|
| 37 |
+
stderr=subprocess.PIPE
|
| 38 |
+
)
|
| 39 |
|
| 40 |
import gradio as gr
|
| 41 |
import fitz # PyMuPDF
|
|
|
|
| 90 |
browser.close()
|
| 91 |
except Exception as e:
|
| 92 |
print(f"Playwright headless fetch failed: {e}. Falling back to requests...")
|
|
|
|
| 93 |
response = requests.get(url, headers=headers, timeout=10)
|
| 94 |
response.raise_for_status()
|
| 95 |
html_content = response.content
|