forked from madgik/exareme2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_post_request.py
63 lines (51 loc) · 1.48 KB
/
example_post_request.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import requests
from devtools import debug
from mipengine.controller.api.algorithm_request_dto import AlgorithmInputDataDTO
from mipengine.controller.api.algorithm_request_dto import AlgorithmRequestDTO
def do_post_request():
url = "http://127.0.0.1:5000/algorithms" + "/logistic_regression"
data_model = "dementia:0.1"
datasets = [
"edsd0",
"edsd1",
"edsd2",
"edsd3",
"edsd4",
"edsd5",
"edsd6",
"edsd7",
"edsd8",
"edsd9",
]
x = [
"lefthippocampus",
"righthippocampus",
"rightppplanumpolare",
"leftamygdala",
"rightamygdala",
]
y = ["alzheimerbroadcategory"]
filters = None
classes = ["AD", "CN"]
algorithm_input_data = AlgorithmInputDataDTO(
data_model=data_model,
datasets=datasets,
filters=filters,
x=x,
y=y,
)
algorithm_request = AlgorithmRequestDTO(
inputdata=algorithm_input_data,
parameters={"classes": classes},
)
debug(algorithm_request)
print(f"POSTing to {url}")
request_json = algorithm_request.json()
headers = {"Content-type": "application/json", "Accept": "text/plain"}
response = requests.post(url, data=request_json, headers=headers)
return response
if __name__ == "__main__":
response = do_post_request()
print(f"\nResponse:")
print(f"Status code-> {response.status_code}")
print(f"Algorithm result-> {response.text}")