-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
43 lines (40 loc) · 1.3 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
40
41
42
43
import flask
import openCV_pic as cvtest
from flask import jsonify,render_template
import openCV_pic2 as cvtest2
app = flask.Flask(__name__)
app.config["DEBUG"] = True
ar_type={"id":1,"face":True,"name":"andy"}
@app.route('/', methods=['GET'])
def home():
return "<h1>Hello Flask!</h1> <h3>This is a face recognition website</h3>"
@app.route('/face', methods=['GET'])
def show_face():
return render_template('face.html')
@app.route('/getface/<int:Istrain>', methods=['POST','GET'])
def getface(Istrain):
if(Istrain==1):
Istrain=True
else :
Istrain=False
# if(flask.request.method=='POST'):
# Istrain=True
print(Istrain)
list_img_filepath=cvtest.build_keras_model(Istrain)
image_html="<img src=\"{image_path}\" alt=\"User Image\">"
final_html=""
for(i,k) in enumerate(list_img_filepath):
final_html=final_html+image_html.format(image_path=k)
return render_template('app.html',image_list=list_img_filepath)
@app.route('/index', methods=['GET'])
def show_page():
return render_template('index.html',user_image="<h1>GO GO FACE!</h1>")
#return json
#return jsonify(ar_type)
#未完成
@app.route('/test', methods=['GET'])
def test_page():
cvtest2.build_keras_model()
return "<h1>test</h1>"
# web api run
app.run(port=5000, debug=True)