fix order in json out + test x file list ordinata

This commit is contained in:
Marco Locatelli
2021-04-02 18:12:40 +02:00
parent 8b701b47e6
commit 99cd8e7baf
2 changed files with 11 additions and 1 deletions
+11
View File
@@ -8,6 +8,8 @@ import os
import json
from werkzeug.utils import redirect
import os.path, time
#from pathlib import Path
#from stat import S_ISREG, ST_CTIME, ST_MODE
#assegno ipv4 statico
ipv4 = '10.74.83.210'
@@ -25,6 +27,7 @@ def getRedisVal(redisKey):
return redSrv0.get(redisKey).decode('utf-8')
flaskApp = Flask(__name__)
flaskApp.config['JSON_SORT_KEYS'] = False
@flaskApp.route("/")
#funzione main: passa al template home il titolo
def main():
@@ -131,8 +134,16 @@ def api_channels_current():
def api_get_files():
dataDir='/home/pi/data/'
fileList = os.listdir(dataDir)
# #all entries in the directory w/ stats
# data = (os.path.join(dataDir, fn) for fn in os.listdir(dataDir))
# data = ((os.stat(path), path) for path in data)
# # regular files, insert creation date
# data = ((stat[ST_CTIME], path)
# for stat, path in data if S_ISREG(stat[ST_MODE]))
lista = []
idx=0
# for item in sorted(data):
for item in fileList:
t_obj = time.strptime(time.ctime(os.path.getctime(dataDir+item)))
# Transforming the time object to a timestamp
-1
View File
@@ -229,7 +229,6 @@
</div>
</div>
<div class="card-body">
<p class="text-center" id="showData"></p>
</div>
</div>