add username to downloads folder

This commit is contained in:
2023-06-13 10:09:01 +02:00
parent a1f78619fa
commit 357f0649f1
2 changed files with 10 additions and 1 deletions

View File

@@ -9,4 +9,8 @@
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"sonarlint.connectedMode.project": {
"connectionId": "doctorado-ml",
"projectKey": "Doctorado-ML_beflask"
},
}

View File

@@ -195,8 +195,13 @@ def excel():
def download(file_name):
os.chdir(current_user.benchmark.folder)
src = os.path.join(current_user.benchmark.folder, Folders.excel, file_name)
dest = os.path.join("static", "excel", file_name)
dest_path = os.path.join("static", "excel", current_user.username)
dest = os.path.join(dest_path, file_name)
os.chdir(current_app.root_path)
try:
os.makedirs(dest_path)
except FileExistsError:
pass
shutil.copyfile(src, dest)
return send_file(dest, as_attachment=True)