From 2956937c646707fb726be9843280c8969981cdd5 Mon Sep 17 00:00:00 2001 From: David Itehua Xalamihua Date: Sun, 11 May 2025 17:32:04 -0600 Subject: [PATCH] se mejora el manejo de ruta uploads para windows y linux --- main.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 1506eaf..ad08105 100644 --- a/main.py +++ b/main.py @@ -23,6 +23,21 @@ from functools import wraps from flask_caching import Cache +import platform + + +folder_upload = None + +if 'microsoft' in platform.uname().release.lower(): + # folder_upload = os.path.join(os.getcwd(), "/static/uploads/") + folder_upload = os.path.join(os.getcwd(), "static", "uploads") + +elif platform.system() == "Linux": + folder_upload = "/var/www/formha/static/uploads/" + + + + app = Flask(__name__) cache = Cache(app, config={'CACHE_TYPE': 'filesystem', 'CACHE_DIR': '/tmp/flask-formha'}) @@ -1058,7 +1073,7 @@ def carousel(): ORDER BY id DESC; """ - + data = dbUsers.get_all_data(q_all_slides, ()) if request.method == 'POST' and form.validate_on_submit(): @@ -1077,7 +1092,9 @@ def carousel(): if filename in lst_img: mnsj_flash = l_flash_msj('Error Archivo', 'La imagen ya ha sido cargada previamente.', 'error') else: - image_file.save(f'./static/uploads/{filename}') + # image_file.save(f'./static/uploads/{filename}') + image_file.save(os.path.join(folder_upload, filename)) + bg_color = rgba_to_string((*hex_to_rgb(form.bg_color.data), 0.5)) txt_color = rgba_to_string((*hex_to_rgb(form.txt_color.data), 1)) txt = form.txt.data