1 from django.shortcuts import render
2 from django.http import HttpResponse, HttpRequest
9 from django.views.decorators.csrf import csrf_exempt
12 dir_list = os.listdir("logs/")
13 connection = sqlite3.connect("logs/"+dir_list[0])
14 cursor = connection.cursor()
15 rows = cursor.execute(query).fetchall()
19 def index(request,devicename):
20 if request.path[0:8] == "/devices":
21 dev=list(load_db("select cast(device as text) from devices where devkey = \""+devicename+"\""))
23 #dev_string = "{ \"recordsTotal\": "+str(dev_count)+", \"data\": ["
24 #dev_list = list(load_db("select cast(device as text) from devices limit 50"))
25 #for device in dev_list:
27 # dev_string = dev_string + dev + ","
28 #dev_string = dev_string[:-1]
29 #dev_string = dev_string + "],\"draw\": 5,\"recordsFiltered\": "+str(dev_count)+"}"
30 return HttpResponse(dev_info, content_type='text/json')
31 elif request.path[0:11] == "/datasource":
32 datasource=list(load_db("select cast(json as text) from datasources where uuid = \""+str(devicename)+"\""))
33 (json_result,) = datasource[0]
34 return HttpResponse(json_result, content_type='text/json')
35 elif request.path[0:4] == "/phy":
36 #INCOMPLETE - Need to work out device mappings still
37 devices=list(load_db("select cast(device as text) from devices where type='Wi-Fi AP'"))
38 for device in devices:
39 (json_result,) = device
40 device_json = json.loads(json_result)
42 if str(devicename) == str(device_json['dot11.device']['dot11.device.last_beaconed_ssid_record']['dot11.advertisedssid.ssid_hash']):
47 return HttpResponse("{}", content_type='text/json')