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 #connection.row_factory = lambda cursor, row: row[0]
15 cursor = connection.cursor()
16 rows = cursor.execute(query).fetchall()
20 def index(request,devicename):
21 #print("-------------")
24 #print("-------------")
25 if request.path[0:8] == "/devices":
26 dev=list(load_db("select cast(device as text) from devices where devkey = \""+devicename+"\""))
28 #dev_string = "{ \"recordsTotal\": "+str(dev_count)+", \"data\": ["
29 #dev_list = list(load_db("select cast(device as text) from devices limit 50"))
30 #for device in dev_list:
32 # dev_string = dev_string + dev + ","
33 #dev_string = dev_string[:-1]
34 #dev_string = dev_string + "],\"draw\": 5,\"recordsFiltered\": "+str(dev_count)+"}"
35 return HttpResponse(dev_info, content_type='text/json')
36 elif request.path[0:11] == "/datasource":
37 datasource=list(load_db("select cast(json as text) from datasources where uuid = \""+str(devicename)+"\""))
38 (json_result,) = datasource[0]
39 return HttpResponse(json_result, content_type='text/json')