-
Notifications
You must be signed in to change notification settings - Fork 0
/
koi.py
40 lines (31 loc) · 832 Bytes
/
koi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import requests
BASE_URL = "http://127.0.0.1:8000/"
OBJECT = "object"
OBJECT_LINK = "object/link"
SET = "set"
LINK = "link"
LLM = "llm"
CREATE = "POST"
READ = "GET"
UPDATE = "PUT"
DELETE = "DELETE"
def make_request(method, endpoint, **params):
response = requests.request(method, BASE_URL + endpoint, json=params)
data = response.json()
if response.status_code != 200:
# print("error:")
# for k, v in data.items():
# print(f"\t{k}: {v}")
response.raise_for_status()
# print(method, "->", endpoint)
# print("input:")
# for k, v in params.items():
# print(f"\t{k}: {v}")
# print("output:")
# if type(data) is dict:
# for k, v in data.items():
# print(f"\t{k}: {v}")
# else:
# print(data)
# print()
return data