diff options
author | Kristofer Hallin <kristofer@sunet.se> | 2021-10-06 21:48:53 +0200 |
---|---|---|
committer | Kristofer Hallin <kristofer@sunet.se> | 2021-10-06 21:48:53 +0200 |
commit | 6aafba52d7a3f6f03b85d9df35972eb6564d36ed (patch) | |
tree | 36573e8e476dd9238469eea635719c5fee27e6ef /src/wsgi.py | |
parent | ba8ec01914aa7d8f122f9a968199ffc04b08ec69 (diff) |
Create indexes when creating database, also make it possible to search based on indexes.
Diffstat (limited to 'src/wsgi.py')
-rwxr-xr-x | src/wsgi.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/wsgi.py b/src/wsgi.py index e1f645c..54d18d3 100755 --- a/src/wsgi.py +++ b/src/wsgi.py @@ -4,6 +4,7 @@ import os import sys import json import authn +import index import falcon from db import DictDB @@ -46,7 +47,9 @@ class CollectorResource(): class EPGet(CollectorResource): def on_get(self, req, resp): - out = [] + out = list() + selectors = dict() + resp.status = falcon.HTTP_200 resp.content_type = falcon.MEDIA_JSON orgs = self.user_auth(req.auth, self._users.read_perms) @@ -57,9 +60,11 @@ class EPGet(CollectorResource): {'status': 'error', 'message': 'Invalid username or password\n'}) return - # We really shouldn't rely on req.params in its pure form since - # it might contain garbage. - selectors = req.params + for param in req.params: + for i in index.indexes: + for j in i['index']['fields']: + if j == param: + selectors[param] = req.params[param] for org in orgs: selectors['domain'] = org |