1 Star 0 Fork 0

ehealth/faceapp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
faceapp.py 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
silence 提交于 2017-04-21 14:52 . 'ini配置'
#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
@time: 2017/3/24 16:04
@author: Silence
'''
import os
from flask import Flask, request,send_file,render_template,url_for,jsonify
from flask_uploads import UploadSet, configure_uploads, IMAGES,\
patch_request_class
import tool_output_landmarks_image
import time
app = Flask(__name__)
# app.config['UPLOADED_PHOTOS_DEST'] = os.path.join(os.getcwd(),'static','uploads') # 文件储存地址
# app.config['UPLOADED_PHOTOS_DEST'] = 'C:\Users\Silance\PycharmProjects\markFace\static\images\uploads' # 文件储存地址
app.config['UPLOADED_PHOTOS_DEST'] = os.path.join('static','images','uploads') # 文件储存地址
photos = UploadSet('photos', IMAGES)
configure_uploads(app, photos)
patch_request_class(app) # 文件大小限制,默认为16MB
@app.route('/', methods=['GET'])
def index():
return render_template('face.html')
@app.route('/markapi', methods=['POST'])
def upload_file():
if 'photo' in request.files:
filename = photos.save(request.files['photo'])
a,b = filename.split('.')
newFileName = a+'.jpg'
# print filename
file_url = photos.url(filename)
infile_path = os.path.join(os.getcwd(),'static','images','uploads',filename)
outfile_path = os.path.join(os.getcwd(),'static','images','markface',newFileName)
tool_output_landmarks_image.main(infile_path,outfile_path)
# return send_file('static/uploads/'+filename,mimetype='image/jpeg')
# return send_file(os.path.join('static','images','markface',filename),mimetype='image/jpeg')
url = url_for('static', filename='images/markface/%s' % newFileName)
if url:
data = {
'markImage': 'http://117.114.138.52:10302%s' % url,
'resultMessage': '200'
}
return jsonify(data)
else:
data = {
'resultMessage': '500'
}
return jsonify(data)
else:
return u'参数错误'
if __name__ == '__main__':
app.run()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/researchimage/faceapp.git
git@gitee.com:researchimage/faceapp.git
researchimage
faceapp
faceapp
master

搜索帮助