From 9b42192e54b409b7d6c1a12a8d802bc1edbaf37c Mon Sep 17 00:00:00 2001 From: Kristofer Hallin Date: Wed, 13 Oct 2021 08:49:34 +0200 Subject: Now possible to get data based on a single key. --- src/wsgi.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wsgi.py b/src/wsgi.py index 54d18d3..97965e1 100755 --- a/src/wsgi.py +++ b/src/wsgi.py @@ -46,7 +46,7 @@ class CollectorResource(): class EPGet(CollectorResource): - def on_get(self, req, resp): + def on_get(self, req, resp, key=None): out = list() selectors = dict() @@ -60,6 +60,11 @@ class EPGet(CollectorResource): {'status': 'error', 'message': 'Invalid username or password\n'}) return + if key: + out = self._db.get(key) + resp.text = json.dumps({'status': 'success', 'data': out}) + return + for param in req.params: for i in index.indexes: for j in i['index']['fields']: @@ -131,7 +136,8 @@ def main(port=8000, wsgi_helper=False): users = authn.UserDB('wsgi_demo_users.yaml') resources_map = [ ('/sc/v0/add', EPAdd(db, users)), - ('/sc/v0/get', EPGet(db, users)) + ('/sc/v0/get', EPGet(db, users)), + ('/sc/v0/get/{key}', EPGet(db, users)) ] app = falcon.App(cors_enable=True) -- cgit v1.1