1、Flask服务端内容(Flask+uwsgi+supervisor搭建):
一、apk包上传服务
<form action="/api/upload" method="post" enctype="multipart/form-data">
<p>
<input type="file" name="file" >
<input type =submit value="upload">
</p>
</form>
此表单用来上传apk,post调用/api/upload的业务逻辑:
ALLOWED_EXTENSIONS = set(['apk'])#定义只包含apk后缀的文件
//判断文件是否为apk包
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS
if request.method == 'POST':
file = request.files["file"]
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
base_path = path.abspath(path.dirname(__file__))
upload_path = path.join(base_path, '../static/uploads/apk/')
file_name = upload_path + filename
target_url = request.host_url+'static/upl