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":
27 dev=list(load_db("select cast(device as text) from devices where devkey = \""+devicename+"\""))
29 #dev_string = "{ \"recordsTotal\": "+str(dev_count)+", \"data\": ["
30 #dev_list = list(load_db("select cast(device as text) from devices limit 50"))
31 #for device in dev_list:
33 # dev_string = dev_string + dev + ","
34 #dev_string = dev_string[:-1]
35 #dev_string = dev_string + "],\"draw\": 5,\"recordsFiltered\": "+str(dev_count)+"}"
36 return HttpResponse(dev_info, content_type='text/json')
37 elif request.path[0:11] == "/datasource":
38 datasource=list(load_db("select cast(json as text) from datasources where uuid = \""+str(devicename)+"\""))
39 (json_result,) = datasource[0]
40 return HttpResponse(json_result, content_type='text/json')