From 67bfc5c103564e7ea1891a00fc18cc1536f6081c Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Tue, 11 Feb 2025 11:34:47 -0800 Subject: [PATCH] feat: Add file browser selector for headless server directory selection --- src/streamlit_app.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/streamlit_app.py b/src/streamlit_app.py index d130316..ba0f806 100644 --- a/src/streamlit_app.py +++ b/src/streamlit_app.py @@ -3,6 +3,7 @@ import os import logging import warnings import shutil +from streamlit_file_browser_selector import st_file_browser_selector from io import BytesIO import tempfile import zipfile @@ -187,6 +188,19 @@ with col1: key='source_dir_input', help="Enter the full path to the directory containing files to process") + col_src1, col_src2 = st.columns([1, 4]) + with col_src1: + if st.button("Browse", key='source_browse'): + selected_path = st_file_browser_selector( + path=source_dir or os.path.expanduser("~"), + key="source_selector", + folder_only=True + ) + if selected_path: + st.session_state['source_dir'] = selected_path + st.session_state['source_dir_input'] = selected_path + st.experimental_rerun() + # Add a check and display for source directory status if source_dir: if os.path.exists(source_dir): @@ -200,6 +214,19 @@ with col1: key='dest_dir_input', help="Enter the full path where processed files will be saved") + col_dest1, col_dest2 = st.columns([1, 4]) + with col_dest1: + if st.button("Browse", key='dest_browse'): + selected_path = st_file_browser_selector( + path=dest_dir or os.path.expanduser("~"), + key="dest_selector", + folder_only=True + ) + if selected_path: + st.session_state['dest_dir'] = selected_path + st.session_state['dest_dir_input'] = selected_path + st.experimental_rerun() + # Add a check and display for destination directory status if dest_dir: dest_parent = os.path.dirname(dest_dir)