Skip to content

Commit

Permalink
Add dotenv support to API
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Nov 5, 2020
1 parent 1de44ad commit 0398df2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions api/api.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from flask import Flask
from flask_restful import Api, Resource
import ECNQueue
import os, dotenv

# Load envrionment variables for ./.env
dotenv.load_dotenv()

# Create Flask App
app = Flask(__name__)

# Create API Interface
api = Api(app)



class Item(Resource):
def get(self, queue: str, number: int) -> str:
"""Returns the JSON representation of the item requested.
Expand Down Expand Up @@ -80,12 +82,9 @@ def get(self) -> list:
list: Dictionaries with the number of items in each queue.
"""
return ECNQueue.getQueueCounts()

api.add_resource(QueueList, "/api/get_queues")
api.add_resource(Item, "/api/<string:queue>/<int:number>")
api.add_resource(Queue, "/api/<string:queue>")



if __name__ == "__main__":
app.run()
api.add_resource(QueueList, "/api/get_queues")
api.add_resource(Item, "/api/<string:queue>/<int:number>")
api.add_resource(Queue, "/api/<string:queue>")

0 comments on commit 0398df2

Please sign in to comment.