diff --git a/api_app.py b/api_app.py index 6ceebf1..00d0a9e 100644 --- a/api_app.py +++ b/api_app.py @@ -67,12 +67,14 @@ def select_all_frames(conn): class Packets(Resource): def get(self): + # Handle arguments that may or may not exist try: n = int(request.args.get('n')) except: n = 10 - print(n) + conn = get_db_connection() + # Limit to number of records requested data = select_all_frames(conn)[-n:] # Sort by created date, descending (https://stackoverflow.com/a/45266808) data.sort(key=operator.itemgetter('created'), reverse=True)