pcdoido2 commited on
Commit
02d5837
·
verified ·
1 Parent(s): 5b966e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -3,7 +3,6 @@ import os
3
  import shutil
4
  import json
5
  import time
6
- from datetime import datetime, timedelta
7
 
8
  UPLOAD_FOLDER = "uploaded_files"
9
  EXPIRATION_FILE = "expirations.json"
@@ -72,26 +71,27 @@ if not files:
72
  st.info("Nenhum arquivo disponível.")
73
  else:
74
  for file in files:
75
- col1, col2, col3, col4 = st.columns([5, 1, 1, 2])
76
- with col1:
77
- expira = expirations.get(file)
78
- if expira:
79
- restante = int(expira - time.time())
80
- if restante > 0:
81
- restante_horas = restante // 3600
82
- restante_min = (restante % 3600) // 60
83
- st.write(f"**{file}** (expira em {restante_horas}h {restante_min}min)")
84
- else:
85
- st.write(f"**{file}** (expiração iminente)")
86
  else:
87
- st.write(f"**{file}**")
88
 
89
- with col2:
 
 
 
90
  with open(os.path.join(UPLOAD_FOLDER, file), "rb") as f_obj:
91
- st.download_button("⬇", f_obj, file_name=file, key=f"down_{file}")
92
 
93
- with col3:
94
- if st.button("🗑", key=f"delete_{file}"):
95
  os.remove(os.path.join(UPLOAD_FOLDER, file))
96
  expirations.pop(file, None)
97
  with open(EXPIRATION_FILE, "w") as f:
@@ -99,9 +99,9 @@ else:
99
  st.success(f"Arquivo '{file}' excluído.")
100
  st.rerun()
101
 
102
- with col4:
103
  with open(os.path.join(UPLOAD_FOLDER, file), "rb") as f_obj:
104
- if st.download_button("⬇ & 🗑", f_obj, file_name=file, key=f"download_delete_{file}"):
105
  os.remove(os.path.join(UPLOAD_FOLDER, file))
106
  expirations.pop(file, None)
107
  with open(EXPIRATION_FILE, "w") as f:
 
3
  import shutil
4
  import json
5
  import time
 
6
 
7
  UPLOAD_FOLDER = "uploaded_files"
8
  EXPIRATION_FILE = "expirations.json"
 
71
  st.info("Nenhum arquivo disponível.")
72
  else:
73
  for file in files:
74
+ st.subheader(f"📄 {file}")
75
+
76
+ expira = expirations.get(file)
77
+ if expira:
78
+ restante = int(expira - time.time())
79
+ if restante > 0:
80
+ restante_horas = restante // 3600
81
+ restante_min = (restante % 3600) // 60
82
+ st.write(f" Expira em {restante_horas}h {restante_min}min")
 
 
83
  else:
84
+ st.write("⚠ Expiração iminente")
85
 
86
+ # Botões abaixo do nome do arquivo
87
+ col1, col2, col3 = st.columns(3)
88
+
89
+ with col1:
90
  with open(os.path.join(UPLOAD_FOLDER, file), "rb") as f_obj:
91
+ st.download_button("⬇ Download", f_obj, file_name=file, key=f"down_{file}")
92
 
93
+ with col2:
94
+ if st.button("🗑 Excluir", key=f"delete_{file}"):
95
  os.remove(os.path.join(UPLOAD_FOLDER, file))
96
  expirations.pop(file, None)
97
  with open(EXPIRATION_FILE, "w") as f:
 
99
  st.success(f"Arquivo '{file}' excluído.")
100
  st.rerun()
101
 
102
+ with col3:
103
  with open(os.path.join(UPLOAD_FOLDER, file), "rb") as f_obj:
104
+ if st.download_button("⬇ Baixar & Apagar", f_obj, file_name=file, key=f"download_delete_{file}"):
105
  os.remove(os.path.join(UPLOAD_FOLDER, file))
106
  expirations.pop(file, None)
107
  with open(EXPIRATION_FILE, "w") as f: