From 04dc0003585b8df81534be23d069292045a6ab32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=81=D0=BB=D0=B8=D1=86=D1=8B=D0=BD=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=28Kislitsyn=5FMG=29?= Date: Tue, 11 Dec 2018 19:08:09 +0400 Subject: [PATCH] =?UTF-8?q?[add]=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D1=81=D0=BE=D0=BD=20=D0=BF=D0=BE=20=D0=BF=D1=83=D1=82?= =?UTF-8?q?=D0=B8=20=D0=BA=20=D1=84=D0=BE=D1=82=D0=BE=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D1=84=D0=B8=D0=B8=20(=D0=B8=D0=B7=20=D0=B8=D0=BD=D0=B4=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + server.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index 35e0dd5..d9a5034 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ venv/* /static/OM Thumbs.db .idea/ +/.vs diff --git a/server.py b/server.py index 6eec464..df9512b 100644 --- a/server.py +++ b/server.py @@ -104,6 +104,25 @@ def search_api(): } return Response(response=json.dumps(result), status=200, mimetype='application/json') +@app.route('/whoin', methods=["POST", ]) +def photo_api(): + path = request.values.get('path') + + es = connections.get_connection() + + results = es.search(index = "faces", + body={ + "query": { + "term" : { "file_name.raw" : path } + } + })['hits'] + + result = { + "count": results['total'], + "hits": [{ "person": item["_source"]["person"], "position": item["_source"]["position"]} for item in results['hits']], + } + + return Response(response=json.dumps(result), status=200, mimetype='application/json') if __name__ == "__main__": parser = ArgumentParser()