feat: Add file browser selector for headless server directory selection

This commit is contained in:
Bobby Abellana (aider) 2025-02-11 11:34:47 -08:00
parent 70ea7c39b3
commit 67bfc5c103

View File

@ -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)