-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflask_client.py
28 lines (22 loc) · 962 Bytes
/
flask_client.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
import requests
login_url = 'http://127.0.0.1:5000/login'
# login as admin
r = requests.post(login_url, json={"username": "admin", "password": "admin"})
token = r.json()['access_token']
# query packets
r = requests.get('http://127.0.0.1:5000/query_packets', headers={'Authorization': f'Bearer {token}'})
print(r.json())
# total packets
r = requests.get('http://127.0.0.1:5000/get_total', headers={'Authorization': f'Bearer {token}'})
print(r.json())
# average size
r = requests.get('http://127.0.0.1:5000/get_average', headers={'Authorization': f'Bearer {token}'})
print(r.json())
# throughput plot
r = requests.get('http://127.0.0.1:5000/get_throughput', headers={'Authorization': f'Bearer {token}'})
with open('get_throughput.png', 'wb') as f:
f.write(r.content)
# packets plot
r = requests.get('http://127.0.0.1:5000/get_packet_plot', headers={'Authorization': f'Bearer {token}'})
with open('get_packet_plot.png', 'wb') as f:
f.write(r.content)