Download src/services/proxy_manager.py from muly10599/FLOW2API: direct link, hf CLI and curl.
- Browser
- Download file 858 Bytes
-
https://huggingface.co/spaces/muly10599/FLOW2API/resolve/main/src/services/proxy_manager.py
- Command line
-
hf download hf://spaces/muly10599/FLOW2API/src/services/proxy_manager.py
-
curl -L -o proxy_manager.py https://huggingface.co/spaces/muly10599/FLOW2API/resolve/main/src/services/proxy_manager.py
858 Bytes
| """Proxy management module""" | |
| from typing import Optional | |
| from ..core.database import Database | |
| from ..core.models import ProxyConfig | |
| class ProxyManager: | |
| """Proxy configuration manager""" | |
| def __init__(self, db: Database): | |
| self.db = db | |
| async def get_proxy_url(self) -> Optional[str]: | |
| """Get proxy URL if enabled, otherwise return None""" | |
| config = await self.db.get_proxy_config() | |
| if config and config.enabled and config.proxy_url: | |
| return config.proxy_url | |
| return None | |
| async def update_proxy_config(self, enabled: bool, proxy_url: Optional[str]): | |
| """Update proxy configuration""" | |
| await self.db.update_proxy_config(enabled, proxy_url) | |
| async def get_proxy_config(self) -> ProxyConfig: | |
| """Get proxy configuration""" | |
| return await self.db.get_proxy_config() | |