catch conencter error on request

This commit is contained in:
Mathieu B 2021-08-01 23:15:28 +02:00
parent 2fe6ee2e6e
commit 2a67fd8e3e

View File

@ -35,11 +35,14 @@ def send_sentence_to_server(sentence):
headers['Client-Port'] = str(config_utils.get_in_config('PORT')) headers['Client-Port'] = str(config_utils.get_in_config('PORT'))
# headers["Authorization"] = config_utils.get_in_config("API_KEY") # headers["Authorization"] = config_utils.get_in_config("API_KEY")
try:
response = requests.post(url_service, response = requests.post(url_service,
headers=headers, headers=headers,
json={'sentence': sentence}) json={'sentence': sentence})
print(bytes.decode(response.content)) print(bytes.decode(response.content))
except ConnectionError:
print("Error connecting to the server (server was probably shutdown during request)...")
def get_server_port(): def get_server_port():