se mejora el manejo de ruta uploads para windows y linux
This commit is contained in:
parent
cf405ba012
commit
2956937c64
21
main.py
21
main.py
@ -23,6 +23,21 @@ from functools import wraps
|
|||||||
from flask_caching import Cache
|
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__)
|
app = Flask(__name__)
|
||||||
cache = Cache(app, config={'CACHE_TYPE': 'filesystem', 'CACHE_DIR': '/tmp/flask-formha'})
|
cache = Cache(app, config={'CACHE_TYPE': 'filesystem', 'CACHE_DIR': '/tmp/flask-formha'})
|
||||||
|
|
||||||
@ -1058,7 +1073,7 @@ def carousel():
|
|||||||
ORDER BY
|
ORDER BY
|
||||||
id DESC;
|
id DESC;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
data = dbUsers.get_all_data(q_all_slides, ())
|
data = dbUsers.get_all_data(q_all_slides, ())
|
||||||
|
|
||||||
if request.method == 'POST' and form.validate_on_submit():
|
if request.method == 'POST' and form.validate_on_submit():
|
||||||
@ -1077,7 +1092,9 @@ def carousel():
|
|||||||
if filename in lst_img:
|
if filename in lst_img:
|
||||||
mnsj_flash = l_flash_msj('Error Archivo', 'La imagen ya ha sido cargada previamente.', 'error')
|
mnsj_flash = l_flash_msj('Error Archivo', 'La imagen ya ha sido cargada previamente.', 'error')
|
||||||
else:
|
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))
|
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_color = rgba_to_string((*hex_to_rgb(form.txt_color.data), 1))
|
||||||
txt = form.txt.data
|
txt = form.txt.data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user