flask实现文件的上传

@app.route("/filetranslate", methods=['POST'])
def filetranslate():
    files = request.files["files"]
    print(files, 12901)
    print(files.filename)
    file = "static/files/" + files.filename
    print(file)
    files.save(file)
    url = urls + '/filetranslate'
    param = {'files': open(file, 'rb')}
    rst = requests.post(url, files=param).content
    try:
        res = json.loads(rst)
    except Exception as e:
        res = {
            'code': -1,
            'message': e
        }
    return res

 

上一篇:一个最简单的flask项目部署到Docker的过程


下一篇:在IIS中部署Flask应用