chg: [backend] Print connection errors on terminal
This commit is contained in:
parent
3a575b0f7f
commit
0ee3f7ac13
1 changed files with 4 additions and 2 deletions
|
@ -21,7 +21,8 @@ def get(url, data={}, api_key=misp_apikey):
|
||||||
full_url = urljoin(misp_url, url)
|
full_url = urljoin(misp_url, url)
|
||||||
try:
|
try:
|
||||||
response = requests.get(full_url, data=data, headers=headers, verify=not misp_skipssl)
|
response = requests.get(full_url, data=data, headers=headers, verify=not misp_skipssl)
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
print(e)
|
||||||
return None
|
return None
|
||||||
return response.json() if response.headers['content-type'].startswith('application/json') else response.text
|
return response.json() if response.headers['content-type'].startswith('application/json') else response.text
|
||||||
|
|
||||||
|
@ -36,7 +37,8 @@ def post(url, data={}, api_key=misp_apikey):
|
||||||
full_url = urljoin(misp_url, url)
|
full_url = urljoin(misp_url, url)
|
||||||
try:
|
try:
|
||||||
response = requests.post(full_url, data=json.dumps(data), headers=headers, verify=not misp_skipssl)
|
response = requests.post(full_url, data=json.dumps(data), headers=headers, verify=not misp_skipssl)
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
print(e)
|
||||||
return None
|
return None
|
||||||
return response.json() if response.headers['content-type'].startswith('application/json') else response.text
|
return response.json() if response.headers['content-type'].startswith('application/json') else response.text
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue