mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
feat(generator): add typed HTTP client to the fetcher service
Implements thin wrapper over fetcher's two main endpoints: GET /data/<user> and POST /fetch. Used by worker.py (rebuilds), api.py (user lookups), and cron.py (bulk refresh). Includes authentication via X-Internal-Token header. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""HTTP client to the fetcher service. Used by api.py, worker.py, cron.py."""
|
||||
import requests
|
||||
|
||||
from . import config
|
||||
|
||||
|
||||
def _headers() -> dict:
|
||||
return {"X-Internal-Token": config.FETCHER_INTERNAL_TOKEN}
|
||||
|
||||
|
||||
def get_data(username: str) -> dict:
|
||||
r = requests.get(f"{config.FETCHER_URL}/data/{username}", headers=_headers(), timeout=30)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
|
||||
def force_fetch(username: str) -> dict:
|
||||
r = requests.post(f"{config.FETCHER_URL}/fetch", headers=_headers(),
|
||||
json={"username": username}, timeout=30)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
Reference in New Issue
Block a user