Update app.py
Browse files
app.py
CHANGED
|
@@ -430,28 +430,26 @@ def FileSidebar():
|
|
| 430 |
for file in all_files:
|
| 431 |
ext = os.path.splitext(file)[1].lower()
|
| 432 |
col1, col2, col3, col4, col5 = st.sidebar.columns([1, 6, 1, 1, 1])
|
| 433 |
-
|
| 434 |
-
with col1:
|
| 435 |
icon = "π" if ext == ".md" else "π" if ext == ".pdf" else "πΌοΈ" if ext in [".png", ".jpg", ".jpeg"] else "π΅" if ext in [".wav", ".mp3"] else "π₯" if ext == ".mp4" else "π"
|
| 436 |
if st.button(icon, key=f"view_{file}"):
|
| 437 |
with open(file, "rb") as f:
|
| 438 |
content = f.read()
|
| 439 |
if ext == ".md":
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
#SpeechSynthesis(content.decode("utf-8"))
|
| 443 |
elif ext == ".pdf":
|
| 444 |
st.download_button("Download PDF", content, file, "application/pdf")
|
| 445 |
st.write("PDF Viewer not natively supported; download to view.")
|
| 446 |
elif ext in [".png", ".jpg", ".jpeg"]:
|
| 447 |
st.image(content, use_column_width=True)
|
| 448 |
elif ext in [".wav", ".mp3"]:
|
| 449 |
-
st.audio(content)
|
| 450 |
elif ext == ".mp4":
|
| 451 |
-
st.video(content)
|
| 452 |
-
with col2:
|
| 453 |
st.markdown(get_table_download_link(file), unsafe_allow_html=True)
|
| 454 |
-
with col3:
|
| 455 |
if st.button("π", key=f"open_{file}"):
|
| 456 |
with open(file, "rb") as f:
|
| 457 |
content = f.read()
|
|
@@ -466,18 +464,15 @@ def FileSidebar():
|
|
| 466 |
st.audio(content, format=f"audio/{ext[1:]}")
|
| 467 |
elif ext == ".mp4":
|
| 468 |
st.video(content, format="video/mp4")
|
| 469 |
-
with col4:
|
| 470 |
if st.button("βΆοΈ", key=f"run_{file}"):
|
| 471 |
if ext == ".md":
|
| 472 |
process_text(open(file, "r", encoding="utf-8").read())
|
| 473 |
-
with col5:
|
| 474 |
if st.button("π", key=f"delete_{file}"):
|
| 475 |
os.remove(file)
|
| 476 |
st.rerun()
|
| 477 |
-
|
| 478 |
-
colFollowUp=ext
|
| 479 |
-
st.markdown(content.decode("utf-8"))
|
| 480 |
-
SpeechSynthesis(content.decode("utf-8"))
|
| 481 |
def create_zip_of_files(files):
|
| 482 |
zip_name = "Files.zip"
|
| 483 |
with zipfile.ZipFile(zip_name, 'w') as zipf:
|
|
|
|
| 430 |
for file in all_files:
|
| 431 |
ext = os.path.splitext(file)[1].lower()
|
| 432 |
col1, col2, col3, col4, col5 = st.sidebar.columns([1, 6, 1, 1, 1])
|
| 433 |
+
with col1: # View
|
|
|
|
| 434 |
icon = "π" if ext == ".md" else "π" if ext == ".pdf" else "πΌοΈ" if ext in [".png", ".jpg", ".jpeg"] else "π΅" if ext in [".wav", ".mp3"] else "π₯" if ext == ".mp4" else "π"
|
| 435 |
if st.button(icon, key=f"view_{file}"):
|
| 436 |
with open(file, "rb") as f:
|
| 437 |
content = f.read()
|
| 438 |
if ext == ".md":
|
| 439 |
+
st.markdown(content.decode("utf-8"))
|
| 440 |
+
SpeechSynthesis(content.decode("utf-8"))
|
|
|
|
| 441 |
elif ext == ".pdf":
|
| 442 |
st.download_button("Download PDF", content, file, "application/pdf")
|
| 443 |
st.write("PDF Viewer not natively supported; download to view.")
|
| 444 |
elif ext in [".png", ".jpg", ".jpeg"]:
|
| 445 |
st.image(content, use_column_width=True)
|
| 446 |
elif ext in [".wav", ".mp3"]:
|
| 447 |
+
st.audio(content, format=f"audio/{ext[1:]}")
|
| 448 |
elif ext == ".mp4":
|
| 449 |
+
st.video(content, format="video/mp4")
|
| 450 |
+
with col2: # Download link
|
| 451 |
st.markdown(get_table_download_link(file), unsafe_allow_html=True)
|
| 452 |
+
with col3: # Open
|
| 453 |
if st.button("π", key=f"open_{file}"):
|
| 454 |
with open(file, "rb") as f:
|
| 455 |
content = f.read()
|
|
|
|
| 464 |
st.audio(content, format=f"audio/{ext[1:]}")
|
| 465 |
elif ext == ".mp4":
|
| 466 |
st.video(content, format="video/mp4")
|
| 467 |
+
with col4: # Run
|
| 468 |
if st.button("βΆοΈ", key=f"run_{file}"):
|
| 469 |
if ext == ".md":
|
| 470 |
process_text(open(file, "r", encoding="utf-8").read())
|
| 471 |
+
with col5: # Delete
|
| 472 |
if st.button("π", key=f"delete_{file}"):
|
| 473 |
os.remove(file)
|
| 474 |
st.rerun()
|
| 475 |
+
|
|
|
|
|
|
|
|
|
|
| 476 |
def create_zip_of_files(files):
|
| 477 |
zip_name = "Files.zip"
|
| 478 |
with zipfile.ZipFile(zip_name, 'w') as zipf:
|