chg: [server] return CyCAT object type in JSON output

main
Alexandre Dulaunoy 2021-05-24 17:07:43 +02:00
parent 52dd1c4a67
commit 1b31fe8504
No known key found for this signature in database
GPG Key ID: 09E2CD4944E6CBCD
1 changed files with 2 additions and 1 deletions

View File

@ -10,7 +10,7 @@ api = Api(app, version=version, title='CyCAT.org API', description='CyCAT - The
import uuid import uuid
import inspect import inspect
import redis import redis
cycat_type = {"1": "Publisher", "2": "Project"}
r = redis.Redis(host='127.0.0.1', port='3033', decode_responses=True) r = redis.Redis(host='127.0.0.1', port='3033', decode_responses=True)
@ -77,6 +77,7 @@ class lookup(Resource):
return{'message': 'Non existing UUID'}, 404 return{'message': 'Non existing UUID'}, 404
t = r.get("u:{}".format(uuid)) t = r.get("u:{}".format(uuid))
h = r.hgetall("{}:{}".format(t, uuid)) h = r.hgetall("{}:{}".format(t, uuid))
h['_cycat_type'] = cycat_type[str(t)]
return (h) return (h)
else: else:
return {'message': 'UUID is incorrect'}, 400 return {'message': 'UUID is incorrect'}, 400