File size: 1,112 Bytes
e874790
 
 
b582b5b
e874790
b582b5b
 
ea40e0d
4a0f7a6
 
 
 
 
 
 
 
 
 
 
ea40e0d
b582b5b
 
4a0f7a6
504b397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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,
    )