Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,27 @@ BASE_FOLDER = "uploaded_files"
|
|
| 7 |
CATEGORIES = ["AVATAR WORLD", "BLOX FRUITS", "TOCA LIFE"]
|
| 8 |
EXPIRATION_FILE = "expirations.json"
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Cria as pastas se não existirem
|
| 11 |
for cat in CATEGORIES:
|
| 12 |
os.makedirs(os.path.join(BASE_FOLDER, cat), exist_ok=True)
|
|
@@ -91,7 +112,9 @@ for categoria in CATEGORIES:
|
|
| 91 |
st.info("Nenhum arquivo na categoria.")
|
| 92 |
else:
|
| 93 |
for file in files:
|
| 94 |
-
st.
|
|
|
|
|
|
|
| 95 |
key = f"{categoria}|||{file}"
|
| 96 |
|
| 97 |
expira = expirations.get(key)
|
|
@@ -100,15 +123,17 @@ for categoria in CATEGORIES:
|
|
| 100 |
if restante > 0:
|
| 101 |
restante_horas = restante // 3600
|
| 102 |
restante_min = (restante % 3600) // 60
|
| 103 |
-
st.
|
|
|
|
|
|
|
| 104 |
else:
|
| 105 |
-
st.
|
| 106 |
|
| 107 |
col1, col2, col3 = st.columns(3)
|
| 108 |
|
| 109 |
with col1:
|
| 110 |
with open(os.path.join(folder, file), "rb") as f_obj:
|
| 111 |
-
st.download_button("⬇ Download", f_obj, file_name=file, key=f"down_{categoria}_{file}
|
| 112 |
|
| 113 |
with col2:
|
| 114 |
if st.button("🗑 Excluir", key=f"delete_{categoria}_{file}"):
|
|
@@ -128,3 +153,5 @@ for categoria in CATEGORIES:
|
|
| 128 |
json.dump(expirations, f)
|
| 129 |
st.success(f"Arquivo '{file}' baixado e removido.")
|
| 130 |
st.rerun()
|
|
|
|
|
|
|
|
|
| 7 |
CATEGORIES = ["AVATAR WORLD", "BLOX FRUITS", "TOCA LIFE"]
|
| 8 |
EXPIRATION_FILE = "expirations.json"
|
| 9 |
|
| 10 |
+
# --- Estilos CSS ---
|
| 11 |
+
st.markdown("""
|
| 12 |
+
<style>
|
| 13 |
+
.file-box {
|
| 14 |
+
border: 1px solid #ccc;
|
| 15 |
+
padding: 10px;
|
| 16 |
+
margin-bottom: 10px;
|
| 17 |
+
border-radius: 5px;
|
| 18 |
+
background-color: #f9f9f9;
|
| 19 |
+
}
|
| 20 |
+
.file-name {
|
| 21 |
+
font-size: 18px;
|
| 22 |
+
font-weight: bold;
|
| 23 |
+
}
|
| 24 |
+
.expire-text {
|
| 25 |
+
font-size: 14px;
|
| 26 |
+
color: #555;
|
| 27 |
+
}
|
| 28 |
+
</style>
|
| 29 |
+
""", unsafe_allow_html=True)
|
| 30 |
+
|
| 31 |
# Cria as pastas se não existirem
|
| 32 |
for cat in CATEGORIES:
|
| 33 |
os.makedirs(os.path.join(BASE_FOLDER, cat), exist_ok=True)
|
|
|
|
| 112 |
st.info("Nenhum arquivo na categoria.")
|
| 113 |
else:
|
| 114 |
for file in files:
|
| 115 |
+
st.markdown(f"<div class='file-box'>", unsafe_allow_html=True)
|
| 116 |
+
st.markdown(f"<div class='file-name'>{file}</div>", unsafe_allow_html=True)
|
| 117 |
+
|
| 118 |
key = f"{categoria}|||{file}"
|
| 119 |
|
| 120 |
expira = expirations.get(key)
|
|
|
|
| 123 |
if restante > 0:
|
| 124 |
restante_horas = restante // 3600
|
| 125 |
restante_min = (restante % 3600) // 60
|
| 126 |
+
st.markdown(
|
| 127 |
+
f"<div class='expire-text'>⏳ Expira em {restante_horas}h {restante_min}min</div>",
|
| 128 |
+
unsafe_allow_html=True)
|
| 129 |
else:
|
| 130 |
+
st.markdown("<div class='expire-text'>⚠ Expiração iminente</div>", unsafe_allow_html=True)
|
| 131 |
|
| 132 |
col1, col2, col3 = st.columns(3)
|
| 133 |
|
| 134 |
with col1:
|
| 135 |
with open(os.path.join(folder, file), "rb") as f_obj:
|
| 136 |
+
st.download_button("⬇ Download", f_obj, file_name=file, key=f"down_{categoria}_{file})
|
| 137 |
|
| 138 |
with col2:
|
| 139 |
if st.button("🗑 Excluir", key=f"delete_{categoria}_{file}"):
|
|
|
|
| 153 |
json.dump(expirations, f)
|
| 154 |
st.success(f"Arquivo '{file}' baixado e removido.")
|
| 155 |
st.rerun()
|
| 156 |
+
|
| 157 |
+
st.markdown("</div>", unsafe_allow_html=True)
|