Update main.py
Browse files
main.py
CHANGED
|
@@ -3,16 +3,24 @@ from playwright.async_api import BrowserType
|
|
| 3 |
|
| 4 |
_original_launch = BrowserType.launch
|
| 5 |
|
| 6 |
-
|
| 7 |
async def _patched_launch(self, *args, **kwargs):
|
| 8 |
custom_proxy = os.environ.get("MY_CUSTOM_PROXY")
|
| 9 |
-
print(f"!!! Nova Check: Proxy is {custom_proxy} !!!")
|
| 10 |
if custom_proxy:
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
return await _original_launch(self, *args, **kwargs)
|
| 13 |
|
| 14 |
-
|
| 15 |
BrowserType.launch = _patched_launch
|
|
|
|
| 16 |
"""Service entrypoint compatible with Render-style deployment."""
|
| 17 |
|
| 18 |
import os
|
|
|
|
| 3 |
|
| 4 |
_original_launch = BrowserType.launch
|
| 5 |
|
|
|
|
| 6 |
async def _patched_launch(self, *args, **kwargs):
|
| 7 |
custom_proxy = os.environ.get("MY_CUSTOM_PROXY")
|
|
|
|
| 8 |
if custom_proxy:
|
| 9 |
+
try:
|
| 10 |
+
auth_part, url_part = custom_proxy.split("@")
|
| 11 |
+
username, password = auth_part.replace("http://", "").split(":")
|
| 12 |
+
server_url = "http://" + url_part
|
| 13 |
+
kwargs["proxy"] = {
|
| 14 |
+
"server": server_url,
|
| 15 |
+
"username": username,
|
| 16 |
+
"password": password
|
| 17 |
+
}
|
| 18 |
+
except Exception as e:
|
| 19 |
+
print(f"Proxy parse error: {e}")
|
| 20 |
return await _original_launch(self, *args, **kwargs)
|
| 21 |
|
|
|
|
| 22 |
BrowserType.launch = _patched_launch
|
| 23 |
+
|
| 24 |
"""Service entrypoint compatible with Render-style deployment."""
|
| 25 |
|
| 26 |
import os
|