diff options
Diffstat (limited to 'src/pydrilla')
-rw-r--r-- | src/pydrilla/pydrilla.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/pydrilla/pydrilla.py b/src/pydrilla/pydrilla.py index 2e91b89..3e5edc8 100644 --- a/src/pydrilla/pydrilla.py +++ b/src/pydrilla/pydrilla.py @@ -661,18 +661,19 @@ def index(): def get_item(identifier, item_type): ver = request.args.get('ver') + if ver == 'all': - definitions = content().get_item_all_versions(item_type, identifier) - return json.dumps(definitions) - if ver is not None: - try: - ver = normalize_version(parse_version(ver)) - except: - abort(400) + definition = content().get_item_all_versions(item_type, identifier) + else: + if ver is not None: + try: + ver = normalize_version(parse_version(ver)) + except: + abort(400) - definition = content().find_item(item_type, identifier, ver) - if definition is None: - abort(404) + definition = content().find_item(item_type, identifier, ver) + if definition is None: + abort(404) return json.dumps(definition) @@ -681,3 +682,11 @@ for item_type in ['mapping', 'resource']: return get_item(identifier, item_type) bp.add_url_rule(f'/{item_type}s/<string:identifier>', item_type, _get_item) + +@bp.route('/licenses/<string:identifier>') +def get_license(identifier): + definition = content().licenses.get(identifier) + if definition is None: + abort(404) + + return json.dumps(definition) |