2023-06-19 04:03:31 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""ActivityPub settings, fetch & post"""
|
|
|
|
import httpx
|
2023-06-19 08:33:24 +02:00
|
|
|
from demo import config
|
2023-06-19 04:03:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
def fetch(
|
|
|
|
url: str,
|
|
|
|
) -> dict:
|
|
|
|
"""Fetch url and return json"""
|
|
|
|
print(f"fetch {url}")
|
|
|
|
|
|
|
|
with httpx.Client() as client:
|
|
|
|
resp = client.get(
|
|
|
|
url,
|
|
|
|
headers={
|
|
|
|
"User-Agent": config.USER_AGENT,
|
|
|
|
"Accept": config.AP_CONTENT_TYPE,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
return resp.json()
|