diff --git a/api_app.py b/api_app.py index 338662b..b4f3da8 100644 --- a/api_app.py +++ b/api_app.py @@ -5,7 +5,7 @@ import configparser import csv import ast import glob -import json +import json, operator import sqlite3 api_app = Flask(__name__) api = Api(api_app) @@ -51,7 +51,6 @@ def dict_factory(cursor, row): def get_db_connection(): conn = sqlite3.connect('database.db') - #conn.row_factory = sqlite3.Row conn.row_factory = dict_factory return conn @@ -71,6 +70,9 @@ class Packets(Resource): #data = read_logs(log_folder) conn = get_db_connection() data = select_all_frames(conn) + # Sort by created date, descending (https://stackoverflow.com/a/45266808) + data.sort(key=operator.itemgetter('created'), reverse=True) + #data.sort(key=created, reverse=True) return {'data': data}, 200 # return data and 200 OK code # Read config