diff options
author | Kristofer Hallin <kristofer@sunet.se> | 2021-10-13 08:49:34 +0200 |
---|---|---|
committer | Kristofer Hallin <kristofer@sunet.se> | 2021-10-13 08:49:34 +0200 |
commit | 9b42192e54b409b7d6c1a12a8d802bc1edbaf37c (patch) | |
tree | 6df47c40192b7ab4d64fd057b7f18aea9f472483 /src/wsgi.py | |
parent | 446d9f04be3602d395407e79e781b7c591b45ad5 (diff) |
Now possible to get data based on a single key.
Diffstat (limited to 'src/wsgi.py')
-rwxr-xr-x | src/wsgi.py | 10 |
1 files 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) |