JeCabrera commited on
Commit
dc46a03
verified
1 Parent(s): fbe527a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -20
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
- file_content = uploaded_file.read().decode('utf-8')
 
 
 
 
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 these two lines to eliminate the preview
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
- 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
 
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(