forked from ONE-F-M/face_recognition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
39 lines (32 loc) · 1.21 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import json
from flask import Flask, request, jsonify
from face_engine import Detector, set_credential
app = Flask(__name__)
@app.route("/")
def home():
return "Hello, World!"
@app.route('/bigbang', methods=['POST'])
def bigbang():
data = request.get_json()
if not (data.get('cred') and data.get('bucketpath')):
return jsonify({'error':True, 'message':'Blackhole, Dead Star.'})
if not (data['cred'].get('private_key_id') and data['cred'].get('project_id')):
return jsonify({'error':True, 'message':'Blackhole, Dead Star.'})
return jsonify(set_credential(data))
@app.route("/enroll", methods=['POST'])
def enroll():
data = request.get_json()
# use detector
detector = Detector(username=data['username'], bucketpath=data['bucketpath'])
res = detector.enroll(video=data['video'], filename=data['filename'])
return jsonify(res)
@app.route("/verify", methods=['POST'])
def verify():
data = request.get_json()
# print(data)
# use detector
detector = Detector(username=data['username'], bucketpath=data['bucketpath'])
res = detector.verify(video=data['video'], filename=data['filename'])
return jsonify(res)
if __name__ == "__main__":
app.run(debug=True)