diff options
Diffstat (limited to 'check/app/server/api.py')
| -rw-r--r-- | check/app/server/api.py | 25 |
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, }) |
