app.py
1.45 KB
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
import sys, os
from face_emotion_recognition import face_recognition
from flask import Flask, render_template
from flask.globals import request
from werkzeug.utils import secure_filename
# Flask 객체 인스턴스 생성
app = Flask(__name__)
@app.route('/', methods=('GET', 'POST')) # 접속하는 url
def index():
if request.method == 'POST':
print(request.form.get('user'))
user = request.form.get('user')
data = {'level' : 50, 'point' : 360, 'exp': 45000}
return render_template('index.html', user = user, data = data)
elif request.method == 'GET':
user = '반원'
data = {'level' : 50, 'point' : 360, 'exp': 45000}
return render_template('index.html', user = user, data=data)
@app.route('/uploadFace', methods=('GET', 'POST'))
def upload_face():
if request.method == 'GET':
return render_template('upload.html')
elif request.method == 'POST':
f = request.files.get('file')
f.save("./face_emotion_recognition/img/" + secure_filename(f.filename))
face_recognition.face_to_npy()
return 'face image uploaded successfully'
@app.route('/uploadVideo', methods=('GET', 'POST'))
def upload_video():
if request.method == 'POST':
f = request.files.get('video')
f.save("./face_emotion_recognition/data/" + secure_filename(f.filename))
return 'video uploaded successfully'
if __name__=="__main__":
app.run(debug=True)