-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
33 lines (25 loc) · 923 Bytes
/
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
from flask import Flask, request, render_template
from smile_detector import SmileDetector
from urllib.request import urlopen
app = Flask(__name__)
smile_detector = SmileDetector()
@app.route('/')
def hello_world(): # put application's code here
return render_template('index.html')
@app.route("/has_smile", methods = ['POST'])
def has_smile():
image_data = request.get_data()
res = smile_detector.smileCheck(image_data)
if res:
return "ok"
return {'smiling': res}
@app.route("/has_smile_json", methods = ['POST'])
def has_smile_json():
json_data = request.json
with urlopen(json_data['image']) as response:
image_data = response.read()
foundFaces = smile_detector.findFaces(image_data)
smiles = smile_detector.smileCheckForFaces(image_data,foundFaces)
return {'smiling': smiles, 'faces': foundFaces}
if __name__ == '__main__':
app.run(host='0.0.0.0')