app.py 1.45 KB
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)