Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,10 +44,9 @@ def init_driver():
|
|
| 44 |
options.add_argument("--disable-gpu")
|
| 45 |
options.add_argument("--window-size=1280,1696")
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
options.binary_location = "/usr/bin/google-chrome"
|
| 49 |
|
| 50 |
-
# Configure ChromeDriver
|
| 51 |
service = Service(
|
| 52 |
executable_path="/usr/bin/chromedriver",
|
| 53 |
service_args=["--verbose", "--log-path=/tmp/chromedriver.log"]
|
|
@@ -56,15 +55,10 @@ def init_driver():
|
|
| 56 |
try:
|
| 57 |
driver = webdriver.Chrome(service=service, options=options)
|
| 58 |
return driver
|
| 59 |
-
except
|
| 60 |
logger.error(f"Driver initialization failed: {str(e)}")
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
driver = webdriver.Chrome(options=options)
|
| 64 |
-
return driver
|
| 65 |
-
except Exception as fallback_e:
|
| 66 |
-
logger.error(f"Fallback driver initialization also failed: {str(fallback_e)}")
|
| 67 |
-
raise
|
| 68 |
|
| 69 |
@app.post("/transcript", response_model=TranscriptResponse)
|
| 70 |
async def get_transcript(request: VideoRequest):
|
|
@@ -153,7 +147,7 @@ async def get_transcript(request: VideoRequest):
|
|
| 153 |
@app.get("/health")
|
| 154 |
async def health_check():
|
| 155 |
paths = {
|
| 156 |
-
"chrome": "/usr/bin/google-chrome-stable",
|
| 157 |
"chromedriver": "/usr/bin/chromedriver"
|
| 158 |
}
|
| 159 |
exists = {name: os.path.exists(path) for name, path in paths.items()}
|
|
@@ -163,6 +157,7 @@ async def health_check():
|
|
| 163 |
"chrome_version": os.popen("/usr/bin/google-chrome-stable --version").read().strip() if exists["chrome"] else "Not found",
|
| 164 |
"chromedriver_version": os.popen("/usr/bin/chromedriver --version").read().strip() if exists["chromedriver"] else "Not found"
|
| 165 |
}
|
|
|
|
| 166 |
if __name__ == "__main__":
|
| 167 |
import uvicorn
|
| 168 |
uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", 7860)))
|
|
|
|
| 44 |
options.add_argument("--disable-gpu")
|
| 45 |
options.add_argument("--window-size=1280,1696")
|
| 46 |
|
| 47 |
+
# CORRECT PATH FOR HUGGING FACE
|
| 48 |
+
options.binary_location = "/usr/bin/google-chrome-stable" # Changed from google-chrome
|
| 49 |
|
|
|
|
| 50 |
service = Service(
|
| 51 |
executable_path="/usr/bin/chromedriver",
|
| 52 |
service_args=["--verbose", "--log-path=/tmp/chromedriver.log"]
|
|
|
|
| 55 |
try:
|
| 56 |
driver = webdriver.Chrome(service=service, options=options)
|
| 57 |
return driver
|
| 58 |
+
except Exception as e:
|
| 59 |
logger.error(f"Driver initialization failed: {str(e)}")
|
| 60 |
+
raise
|
| 61 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
@app.post("/transcript", response_model=TranscriptResponse)
|
| 64 |
async def get_transcript(request: VideoRequest):
|
|
|
|
| 147 |
@app.get("/health")
|
| 148 |
async def health_check():
|
| 149 |
paths = {
|
| 150 |
+
"chrome": "/usr/bin/google-chrome-stable", # Consistent with binary_location
|
| 151 |
"chromedriver": "/usr/bin/chromedriver"
|
| 152 |
}
|
| 153 |
exists = {name: os.path.exists(path) for name, path in paths.items()}
|
|
|
|
| 157 |
"chrome_version": os.popen("/usr/bin/google-chrome-stable --version").read().strip() if exists["chrome"] else "Not found",
|
| 158 |
"chromedriver_version": os.popen("/usr/bin/chromedriver --version").read().strip() if exists["chromedriver"] else "Not found"
|
| 159 |
}
|
| 160 |
+
|
| 161 |
if __name__ == "__main__":
|
| 162 |
import uvicorn
|
| 163 |
uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", 7860)))
|