From 8930e065d2496036b8553c5bd1275461e307a679 Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Mon, 20 Jul 2020 11:20:58 +0200 Subject: [PATCH] [query] add fields list to query --- conf/env.mallirmm | 3 +++ halfapi/lib/query.py | 4 ++-- scripts/get_token.py | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 conf/env.mallirmm create mode 100755 scripts/get_token.py diff --git a/conf/env.mallirmm b/conf/env.mallirmm new file mode 100644 index 0000000..84a379f --- /dev/null +++ b/conf/env.mallirmm @@ -0,0 +1,3 @@ +DEV=1 +DEBUG=1 +DEBUG_ACL=public diff --git a/halfapi/lib/query.py b/halfapi/lib/query.py index aa1244c..f2efcbc 100644 --- a/halfapi/lib/query.py +++ b/halfapi/lib/query.py @@ -70,7 +70,7 @@ def parse_query(q: str = ""): split_ = lambda x : x.split(':') params = dict(map(split_, q.split('|'))) - def select(obj): + def select(obj, fields = []): if 'limit' in params and int(params['limit']) > 0: obj.limit(int(params['limit'])) @@ -78,6 +78,6 @@ def parse_query(q: str = ""): if 'offset' in params and int(params['offset']) > 0: obj.offset(int(params['offset'])) - return [elt for elt in obj.select()] + return [elt for elt in obj.select(*fields)] return select diff --git a/scripts/get_token.py b/scripts/get_token.py new file mode 100755 index 0000000..b4b24ce --- /dev/null +++ b/scripts/get_token.py @@ -0,0 +1,9 @@ +#!/usr/bin/python3 +import requests +import json + +r = requests.post('http://127.0.0.1:3000/auth', + data={'email':'dhenaut', 'password':'a'}) +r_obj = json.loads(r.text) +token = r_obj['token'] +print(token)