Spaces:
Running
Running
Download src/workers/redis_url.py from Leon4gr45/brain: direct link, hf CLI and curl.
- Browser
- Download file 463 Bytes
-
https://huggingface.co/spaces/Leon4gr45/brain/resolve/main/src/workers/redis_url.py
- Command line
-
hf download hf://spaces/Leon4gr45/brain/src/workers/redis_url.py
-
curl -L -o redis_url.py https://huggingface.co/spaces/Leon4gr45/brain/resolve/main/src/workers/redis_url.py
463 Bytes
| """Redis connection URL helpers for worker transports.""" | |
| from __future__ import annotations | |
| from urllib.parse import quote | |
| def redis_connection_url( | |
| host: str, | |
| port: str | int, | |
| password: str | None, | |
| *, | |
| database: int = 0, | |
| ) -> str: | |
| """Build a Redis URL, percent-encoding credentials when authentication is enabled.""" | |
| auth = f":{quote(password, safe='')}@" if password else "" | |
| return f"redis://{auth}{host}:{port}/{database}" | |