summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-04-26 23:13:28 +0200
committerJules Laplace <julescarbon@gmail.com>2019-04-26 23:13:28 +0200
commitf53ed3f0b54364a971f3ed3ad9f943ef431d88e3 (patch)
tree2f16321a8066dbdd7dd53dc4b5c5c65045fa4e34
parent79c5e701aee1f62516d6c3885418e58fb81c3f97 (diff)
api edit
-rw-r--r--check/app/server/api.py25
1 files changed, 8 insertions, 17 deletions
diff --git a/check/app/server/api.py b/check/app/server/api.py
index 9643917..c4878c5 100644
--- a/check/app/server/api.py
+++ b/check/app/server/api.py
@@ -62,37 +62,28 @@ def match():
})
results = search_by_phash(phash=phash, threshold=threshold, limit=limit)
- logging.debug('query took {0:.2g} s.'.format(time.time() - start))
if len(results) == 0:
if add:
hash = sha256_stream(file)
add_phash(sha256=hash, phash=phash, ext=ext)
- if limit == 1:
- return jsonify({
- 'success': True,
- 'match': False,
- 'timing': time.time() - start,
- })
- else:
- return jsonify({
- 'success': True,
- 'match': False,
- 'results': [],
- 'timing': time.time() - start,
- })
+ match = False
+ else:
+ match = True
+
+ logging.debug('query took {0:.2g} s.'.format(time.time() - start))
if limit > 1:
return jsonify({
'success': True,
- 'match': True,
+ 'match': match,
'results': results,
'timing': time.time() - start,
})
return jsonify({
'success': True,
- 'match': True,
- 'closest_match': results[0],
+ 'match': match,
+ 'closest_match': results[0] if len(results) else None,
'timing': time.time() - start,
})