Skip to content

Commit 17a12ba

Browse files
committed
Added logger
* Add logger
1 parent 6d0f263 commit 17a12ba

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

scripts/api/api.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import requests
2+
import logging
23

34

45
def create_data_file(api_url, data_file_data):
@@ -9,7 +10,13 @@ def create_data_file(api_url, data_file_data):
910
headers=headers,
1011
data=data_file_data,
1112
)
12-
print(r)
13+
status = r.status_code
14+
if status != 200:
15+
response = r.json()["message"]
16+
logging.info(response)
17+
else:
18+
response = r.json()["data"]
19+
logging.info(response)
1320

1421

1522
def create_metadata_file(api_url, metadata_file_data):
@@ -20,4 +27,10 @@ def create_metadata_file(api_url, metadata_file_data):
2027
headers=headers,
2128
data=metadata_file_data,
2229
)
23-
print(r)
30+
status = r.status_code
31+
if status != 200:
32+
response = r.json()["message"]
33+
logging.info(response)
34+
else:
35+
response = r.json()["data"]
36+
logging.info(response)

0 commit comments

Comments
 (0)