-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServersEngine.py
41 lines (26 loc) · 893 Bytes
/
ServersEngine.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
37
38
39
40
41
# Imports
import pytz
import requests
import json
from datetime import datetime
from algoritmoAnalise import detectionAlg
def main():
ip = requests.get('https://api.ipify.org').text
URL_AREAS = "http://" + ip + ":8181/services/eventos/api/areas"
header_authentication = {
"Content-Type": "application/json"
}
body_authentication = {
"password": "admin",
"username": "admin"
}
token = requests.post("http://localhost:8181/api/authenticate", headers=header_authentication, data=json.dumps(body_authentication)).json()
print(token['id_token'])
bearer_token = "Bearer " + token['id_token']
headers = {
'Authorization': bearer_token}
areas_json = requests.get(URL_AREAS, headers=headers).json()
print(areas_json)
detectionAlg(areas_json, ip, token['id_token'])
if __name__ == '__main__':
main()