GaboDataScientist commited on
Commit
ec7b947
·
verified ·
1 Parent(s): c9eb201

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -3,6 +3,9 @@ import pandas as pd
3
  import tempfile
4
  import os
5
  import uuid
 
 
 
6
 
7
  def procesar_bases(file1, file2):
8
  try:
@@ -122,19 +125,20 @@ def procesar_bases(file1, file2):
122
 
123
 
124
  # --- Existing code ends here ---
125
- # Guardamos archivos en carpeta temporal
126
- output1 = f"/tmp/facturas_limpias_{uuid.uuid4().hex}.xlsx"
127
- output2 = f"/tmp/partidas_limpias_{uuid.uuid4().hex}.xlsx"
128
- output3 = f"/tmp/partidas_manuales_{uuid.uuid4().hex}.xlsx"
129
 
130
- dff_expanded_final.to_excel(output1, index=False, engine='openpyxl')
131
- dfp_expanded_final.to_excel(output2, index=False, engine='openpyxl')
132
- empty_concepto_2.to_excel(output3, index=False, engine='openpyxl')
133
 
134
- return output1, output2, output3
 
135
 
136
  except Exception as e:
137
- error_file = "/tmp/error.txt"
138
  with open(error_file, "w") as f:
139
  f.write("Error:\n" + str(e))
140
  return error_file, None, None
 
3
  import tempfile
4
  import os
5
  import uuid
6
+ import shutil
7
+
8
+ os.makedirs("outputs", exist_ok=True) # Carpeta pública para los resultados
9
 
10
  def procesar_bases(file1, file2):
11
  try:
 
125
 
126
 
127
  # --- Existing code ends here ---
128
+ uid = uuid.uuid4().hex
129
+ output1_path = f"outputs/facturas_limpias_{uid}.xlsx"
130
+ output2_path = f"outputs/partidas_limpias_{uid}.xlsx"
131
+ output3_path = f"outputs/partidas_manuales_{uid}.xlsx"
132
 
133
+ dff_expanded_final.to_excel(output1_path, index=False, engine='openpyxl')
134
+ dfp_expanded_final.to_excel(output2_path, index=False, engine='openpyxl')
135
+ empty_concepto_2.to_excel(output3_path, index=False, engine='openpyxl')
136
 
137
+ # Devolver rutas relativas (Gradio las convertirá en URLs públicas si usas static_dir="outputs")
138
+ return output1_path, output2_path, output3_path
139
 
140
  except Exception as e:
141
+ error_file = f"outputs/error_{uuid.uuid4().hex}.txt"
142
  with open(error_file, "w") as f:
143
  f.write("Error:\n" + str(e))
144
  return error_file, None, None