不为别的,只为做一个连自己都羡慕的人

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

 

posted @ 2021-10-15 16:19  升级打怪  阅读(165)  评论(0编辑  收藏  举报