| import os |
| from playwright.async_api import BrowserType |
|
|
| _original_launch = BrowserType.launch |
|
|
| async def _patched_launch(self, *args, **kwargs): |
| custom_proxy = os.environ.get("MY_CUSTOM_PROXY") |
| if custom_proxy: |
| try: |
| auth_part, url_part = custom_proxy.split("@") |
| username, password = auth_part.replace("http://", "").split(":") |
| server_url = "http://" + url_part |
| kwargs["proxy"] = { |
| "server": server_url, |
| "username": username, |
| "password": password |
| } |
| except Exception as e: |
| print(f"Proxy parse error: {e}") |
| return await _original_launch(self, *args, **kwargs) |
|
|
| BrowserType.launch = _patched_launch |
|
|
| """Service entrypoint compatible with Render-style deployment.""" |
|
|
| import os |
|
|
| import uvicorn |
|
|
| from src.main import app |
|
|
|
|
| if __name__ == "__main__": |
| from src.core.config import config |
|
|
| port = int(os.environ.get("PORT", config.server_port)) |
| uvicorn.run( |
| "src.main:app", |
| host=config.server_host, |
| port=port, |
| reload=False, |
| ) |
|
|