0

我使用烧瓶框架上传文件 CSV 以将数据 CSV 插入数据库,我正在使用谷歌云 shell 编辑器,但出现这样的错误“没有这样的文件或目录:'files/{file_csv_name}'”

这是我的上传代码:

# I make a folder named "files"
UPLOAD_FOLDER = 'files/'
app.config['UPLOAD_FOLDER'] =  UPLOAD_FOLDER

if request.method == 'POST':
    # this request to get file uploaded using dropzone.js
    f = request.files['file']
    # and then this for access the path for save the file
    file_path = os.path.join(app.config['UPLOAD_FOLDER'], f.filename)
    # I allow file only csv
    if f and allowed_file(f.filename):
        f.save(file_path)
        # process inputing data into database
        hasil = parseCSV(file_path)
        return render_template("testes.html", data=hasil)
    else:
        os.remove(file_path)
        return render_template("testes.html", data="Oh no")

我在谷歌云运行中部署了我的应用程序。不知道为什么无法访问路径或找不到文件夹,还是必须使用谷歌云存储?我也在 google cloud shell 中编写了所有代码。对这个错误有什么建议吗?

4

0 回答 0