COSCUP-ap-demo/demo/activitypub.py

23 lines
444 B
Python
Raw Normal View History

2023-06-19 04:03:31 +02:00
#!/usr/bin/env python3
"""ActivityPub settings, fetch & post"""
import httpx
import config
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()