[feat] add fetch function
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
SouthFox 2023-06-19 10:03:31 +08:00
parent aec555d1b5
commit 51b61d2db7

22
demo/activitypub.py Normal file
View file

@ -0,0 +1,22 @@
#!/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()