Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,7 +71,11 @@ with col1:
|
|
| 71 |
# Handle text files
|
| 72 |
if file_type in ['txt', 'pdf', 'docx']:
|
| 73 |
if file_type == 'txt':
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
elif file_type == 'pdf':
|
| 77 |
try:
|
|
@@ -93,31 +97,30 @@ with col1:
|
|
| 93 |
st.error(f"Error al leer el archivo DOCX: {str(e)}")
|
| 94 |
file_content = ""
|
| 95 |
|
| 96 |
-
# Remove
|
| 97 |
-
# st.write("**Vista previa del contenido:**")
|
| 98 |
-
# st.write(file_content[:500] + "..." if len(file_content) > 500 else file_content)
|
| 99 |
-
|
| 100 |
-
# Just show a success message instead
|
| 101 |
-
st.success(f"Archivo {file_type.upper()} cargado correctamente")
|
| 102 |
|
| 103 |
# Set file type flag
|
| 104 |
is_image = False
|
| 105 |
|
| 106 |
# Handle image files
|
| 107 |
elif file_type in ['jpg', 'jpeg', 'png']:
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
# Selector de f贸rmula
|
| 123 |
formula_type = st.selectbox(
|
|
|
|
| 71 |
# Handle text files
|
| 72 |
if file_type in ['txt', 'pdf', 'docx']:
|
| 73 |
if file_type == 'txt':
|
| 74 |
+
try:
|
| 75 |
+
file_content = uploaded_file.read().decode('utf-8')
|
| 76 |
+
except Exception as e:
|
| 77 |
+
st.error(f"Error al leer el archivo TXT: {str(e)}")
|
| 78 |
+
file_content = ""
|
| 79 |
|
| 80 |
elif file_type == 'pdf':
|
| 81 |
try:
|
|
|
|
| 97 |
st.error(f"Error al leer el archivo DOCX: {str(e)}")
|
| 98 |
file_content = ""
|
| 99 |
|
| 100 |
+
# Remove success message - no notification shown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
# Set file type flag
|
| 103 |
is_image = False
|
| 104 |
|
| 105 |
# Handle image files
|
| 106 |
elif file_type in ['jpg', 'jpeg', 'png']:
|
| 107 |
+
try:
|
| 108 |
+
image = Image.open(uploaded_file)
|
| 109 |
+
st.image(image, caption="Imagen cargada", use_container_width=True)
|
| 110 |
+
|
| 111 |
+
image_bytes = uploaded_file.getvalue()
|
| 112 |
+
image_parts = [
|
| 113 |
+
{
|
| 114 |
+
"mime_type": uploaded_file.type,
|
| 115 |
+
"data": image_bytes
|
| 116 |
+
}
|
| 117 |
+
]
|
| 118 |
+
|
| 119 |
+
# Set file type flag
|
| 120 |
+
is_image = True
|
| 121 |
+
except Exception as e:
|
| 122 |
+
st.error(f"Error al procesar la imagen: {str(e)}")
|
| 123 |
+
is_image = False
|
| 124 |
|
| 125 |
# Selector de f贸rmula
|
| 126 |
formula_type = st.selectbox(
|