forked from mhdaslmnzr/bfh-tinkerhub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
94 lines (33 loc) · 1.53 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from flask import Flask, redirect, url_for, render_template, request,send_from_directory,flash,send_file,after_this_request
import os
import pickle
import lalmam
import itertools
app = Flask(__name__)
port = int(os.environ.get("PORT", 5000))
UPLOAD_FOLDER = 'test'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
@app.route("/" , methods = ["GET", "POST"])
def main_page():
if request.method == "POST":
# try :
img = request.files["file_uploaded"]
#img.save(os.path.join(app.config['UPLOAD_FOLDER'],img.filename))
if img.filename.lower().endswith(('.jpg','.jpeg','.png')):
msg_ret = lalmam.mainFunction(img)
if (msg_ret[0] == "Sorry no faces found in the image!"):
imges = list('static/images/nop/images.jpg')
return render_template("home.html", msg = msg_ret[0] , cont_imr= zip(msg_ret, imges))
else :
imges = os.listdir('static/images/process')
for i in range(len(imges)):
j = 'static/images/process/'+ imges[i]
imges[i] = j
return render_template("home.html" , cont_imgr = zip(msg_ret,imges))
else :
return render_template("home.html" , msg = "Upload an image file")
# except :
# return render_template("home.html" , msg = "Please upload a file and try again")
return render_template("home.html" , msg = "Upload a file")
if __name__ == "__main__":
app.run(debug=True,host='0.0.0.0',port=port)