Skip to content

Commit

Permalink
Add headersOnly flags to API
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Nov 30, 2020
1 parent 21f347c commit d8225d8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions api/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask
from flask import Flask, request
from flask_restful import Api, Resource
import ECNQueue

Expand Down Expand Up @@ -40,7 +40,9 @@ def get(self, queue: str, number: int) -> str:
Returns:
str: JSON representation of the item requested.
"""
return ECNQueue.Item(queue, number, True).toJson()

headersOnly = True if request.args.get("headersOnly") == "True" else False
return ECNQueue.Item(queue, number, headersOnly=headersOnly).toJson()

class Queue(Resource):
def get(self, queue: str) -> str:
Expand All @@ -52,12 +54,12 @@ def get(self, queue: str) -> str:
Returns:
str: JSON representation of the queue requested.
"""
headersOnly = False if request.args.get("headersOnly") == "False" else True
queues_requested = queue.split("+")

queues = []
for queue in queues_requested:
queues.append(ECNQueue.Queue(queue).toJson())

queues.append(ECNQueue.Queue(queue, headersOnly=headersOnly).toJson())
return queues

class QueueList(Resource):
Expand Down Expand Up @@ -88,4 +90,4 @@ def get(self) -> list:


if __name__ == "__main__":
app.run()
app.run()

0 comments on commit d8225d8

Please sign in to comment.