Update app.py
Browse files
app.py
CHANGED
@@ -8,38 +8,68 @@ from dotenv import load_dotenv
|
|
8 |
from datetime import datetime
|
9 |
from PIL import Image
|
10 |
|
|
|
|
|
11 |
load_dotenv()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
# Configuración de la página
|
14 |
st.set_page_config(
|
15 |
page_title="AIdeaText",
|
16 |
layout="wide",
|
17 |
-
page_icon=
|
|
|
18 |
)
|
19 |
|
20 |
-
#
|
21 |
-
ASSETS_DIR = os.path.join(os.path.dirname(__file__), 'assets', 'img')
|
22 |
-
LOGO_PATH = os.path.join(ASSETS_DIR, 'aideaText_logo.png')
|
23 |
-
|
24 |
-
# Función para verificar y cargar el logo
|
25 |
def setup_logo():
|
|
|
|
|
|
|
26 |
try:
|
27 |
if os.path.exists(LOGO_PATH):
|
28 |
-
# Para un logo cuadrado, usamos la misma imagen para ambos parámetros
|
29 |
st.logo(
|
30 |
image=LOGO_PATH,
|
31 |
-
icon_image=LOGO_PATH,
|
32 |
-
size="medium",
|
33 |
-
link="https://aideatext.ai"
|
34 |
)
|
35 |
return True
|
36 |
else:
|
37 |
-
logger.warning("
|
38 |
return False
|
39 |
except Exception as e:
|
40 |
-
logger.error(f"Error
|
41 |
return False
|
42 |
|
|
|
43 |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
44 |
|
45 |
# Importaciones locales
|
|
|
8 |
from datetime import datetime
|
9 |
from PIL import Image
|
10 |
|
11 |
+
|
12 |
+
# Configuración básica
|
13 |
load_dotenv()
|
14 |
+
logging.basicConfig(level=logging.INFO)
|
15 |
+
logger = logging.getLogger(__name__)
|
16 |
+
|
17 |
+
# Definir rutas de archivos de imagen
|
18 |
+
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
19 |
+
ASSETS_DIR = os.path.join(ROOT_DIR, 'assets', 'img')
|
20 |
+
LOGO_PATH = os.path.join(ASSETS_DIR, 'aideaText_logo.png')
|
21 |
+
ICON_PATH = os.path.join(ASSETS_DIR, 'aideaText.ico')
|
22 |
+
|
23 |
+
def load_assets():
|
24 |
+
"""
|
25 |
+
Carga los archivos de imágenes necesarios
|
26 |
+
"""
|
27 |
+
try:
|
28 |
+
# Cargar ícono
|
29 |
+
if os.path.exists(ICON_PATH):
|
30 |
+
icon = Image.open(ICON_PATH)
|
31 |
+
else:
|
32 |
+
icon = "🧠" # Emoji por defecto
|
33 |
+
logger.warning("Archivo de ícono no encontrado")
|
34 |
+
|
35 |
+
return icon
|
36 |
+
except Exception as e:
|
37 |
+
logger.error(f"Error cargando assets: {str(e)}")
|
38 |
+
return "🧠"
|
39 |
+
|
40 |
+
# Cargar ícono antes de la configuración de la página
|
41 |
+
page_icon = load_assets()
|
42 |
|
43 |
+
# Configuración de la página
|
44 |
st.set_page_config(
|
45 |
page_title="AIdeaText",
|
46 |
layout="wide",
|
47 |
+
page_icon=page_icon,
|
48 |
+
initial_sidebar_state="expanded"
|
49 |
)
|
50 |
|
51 |
+
# Configurar el logo
|
|
|
|
|
|
|
|
|
52 |
def setup_logo():
|
53 |
+
"""
|
54 |
+
Configura el logo en la interfaz
|
55 |
+
"""
|
56 |
try:
|
57 |
if os.path.exists(LOGO_PATH):
|
|
|
58 |
st.logo(
|
59 |
image=LOGO_PATH,
|
60 |
+
icon_image=LOGO_PATH,
|
61 |
+
size="medium",
|
62 |
+
link="https://aideatext.ai"
|
63 |
)
|
64 |
return True
|
65 |
else:
|
66 |
+
logger.warning("Archivo de logo no encontrado")
|
67 |
return False
|
68 |
except Exception as e:
|
69 |
+
logger.error(f"Error configurando logo: {str(e)}")
|
70 |
return False
|
71 |
|
72 |
+
|
73 |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
74 |
|
75 |
# Importaciones locales
|