~sircmpwn/core.sr.ht

core.sr.ht/srht/redis.py -rw-r--r-- 308 bytes
b695e020Drew DeVault Add "internal_anon" path for internal auth tokens 3 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
from redis import Redis
from srht.config import cfg
from urllib.parse import urlparse

url = cfg("sr.ht", "redis-host", "redis://localhost")
url = urlparse(url)

redis = Redis(host=url.hostname,
        port=(url.port or 6379),
        password=url.password,
        db=int(url.path[1:]) if url.path else 0)