34 lines
695 B
Python
34 lines
695 B
Python
from http import client
|
|
import logging
|
|
import json
|
|
import yaml
|
|
|
|
host="cwsvjudo.bplaced.net"
|
|
|
|
with open("testApi.config.yaml", "r") as f:
|
|
config = yaml.load(f)
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
connection = client.HTTPConnection(host=host, port=80, timeout=1)
|
|
connection.request(
|
|
method="GET",
|
|
url="/participo/api/users",
|
|
headers={
|
|
"Authorization": f"Basic {config['apiKey']}"
|
|
}
|
|
)
|
|
response = connection.getresponse()
|
|
|
|
print("Status: {} and reason: {}".format(response.status, response.reason))
|
|
|
|
body = response.read()
|
|
try:
|
|
print(json.dumps(json.loads(body),indent=2))
|
|
except:
|
|
print(f"failed to parse to json")
|
|
print(body
|
|
)
|
|
|
|
connection.close()
|