mardi 21 septembre 2021

Download file with Flask and send_from_directory

I have a problem, I am using (send_from_directory) to upload files. But when I want to download a file with spaces in the name or if the name is in Russian, then nothing works for me and gives a 500 error.

@app.route('/api/v1/report/download/<filename>', methods=['GET'])
def download(filename):
    return send_from_directory(app.config['UPLOAD_FOLDER'],
                               filename, as_attachment=True) ```



Aucun commentaire:

Enregistrer un commentaire