-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
36 lines (25 loc) · 790 Bytes
/
test.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
import requests
import json
import time
local = 'http://localhost:3000/detect'
production = 'https://nl-api.max-hitchings.com/detect'
data = {"text" : ["max", "no"]}
start_time = time.time()
request = requests.get(production, json=data)
end_time = time.time()
print(int(round((end_time-start_time)*1000, 0)), "msec")
### Method 1 ###
# Prints plain json
response = request.json()
print(response["result"])
### Method 2 ###
# Removes all null values #~#BEST OPTION#~#
response = request.json()
def remove_values_from_list(the_list, val):
return [value for value in the_list if value != val]
for List in response["result"]:
print(remove_values_from_list(List, None))
### Method 3 ###
# Prints formated json
response = request.json()
print(json.dumps(response, indent=2))