Add comments.
This commit is contained in:
parent
1cffde2903
commit
cd5d24b641
|
@ -67,12 +67,14 @@ def select_all_frames(conn):
|
||||||
|
|
||||||
class Packets(Resource):
|
class Packets(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
|
# Handle arguments that may or may not exist
|
||||||
try:
|
try:
|
||||||
n = int(request.args.get('n'))
|
n = int(request.args.get('n'))
|
||||||
except:
|
except:
|
||||||
n = 10
|
n = 10
|
||||||
print(n)
|
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
|
# Limit to number of records requested
|
||||||
data = select_all_frames(conn)[-n:]
|
data = select_all_frames(conn)[-n:]
|
||||||
# Sort by created date, descending (https://stackoverflow.com/a/45266808)
|
# Sort by created date, descending (https://stackoverflow.com/a/45266808)
|
||||||
data.sort(key=operator.itemgetter('created'), reverse=True)
|
data.sort(key=operator.itemgetter('created'), reverse=True)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user