Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ import streamlit as st
|
|
4 |
import sys
|
5 |
import base64
|
6 |
|
7 |
-
# Function definitions remain the same
|
8 |
def get_ignore_list(ignore_file_path):
|
9 |
ignore_list = []
|
10 |
with open(ignore_file_path, 'r') as ignore_file:
|
@@ -62,44 +61,41 @@ def download_button(object_to_download, download_filename, button_text):
|
|
62 |
st.title("Git Repository Loader with Web UI")
|
63 |
|
64 |
# Organizing input and buttons using columns
|
65 |
-
col1, col2
|
66 |
with col1:
|
67 |
-
|
68 |
with col2:
|
69 |
process_button = st.button("Process Repository")
|
70 |
-
with col3:
|
71 |
-
copy_button = st.button("Copy to Clipboard")
|
72 |
|
73 |
-
if process_button:
|
74 |
with st.spinner('Processing the repository...'):
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
90 |
|
91 |
-
|
92 |
-
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
|
99 |
-
|
100 |
-
st.experimental_set_query_params(full_output=full_output)
|
101 |
-
js = f"navigator.clipboard.writeText(`{full_output}`)"
|
102 |
-
st.components.v1.html(f"<script>{js}</script>", height=0, width=0)
|
103 |
-
st.sidebar.success("Copied to clipboard!")
|
104 |
-
|
105 |
-
st.success("Process completed. Review the results above.")
|
|
|
4 |
import sys
|
5 |
import base64
|
6 |
|
|
|
7 |
def get_ignore_list(ignore_file_path):
|
8 |
ignore_list = []
|
9 |
with open(ignore_file_path, 'r') as ignore_file:
|
|
|
61 |
st.title("Git Repository Loader with Web UI")
|
62 |
|
63 |
# Organizing input and buttons using columns
|
64 |
+
col1, col2 = st.columns([3, 2])
|
65 |
with col1:
|
66 |
+
uploaded_files = st.file_uploader("Drag and drop a folder or click to select a directory:", accept_multiple_files=True)
|
67 |
with col2:
|
68 |
process_button = st.button("Process Repository")
|
|
|
|
|
69 |
|
70 |
+
if process_button and uploaded_files:
|
71 |
with st.spinner('Processing the repository...'):
|
72 |
+
# Temporary directory to store uploaded files
|
73 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
74 |
+
# Save uploaded files to the temporary directory
|
75 |
+
for uploaded_file in uploaded_files:
|
76 |
+
file_path = os.path.join(temp_dir, uploaded_file.name)
|
77 |
+
with open(file_path, "wb") as file:
|
78 |
+
file.write(uploaded_file.getbuffer())
|
79 |
|
80 |
+
ignore_file_path = os.path.join(temp_dir, ".gptignore")
|
81 |
+
if not os.path.exists(ignore_file_path):
|
82 |
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
83 |
+
ignore_file_path = os.path.join(HERE, ".gptignore")
|
84 |
|
85 |
+
if os.path.exists(ignore_file_path):
|
86 |
+
ignore_list = get_ignore_list(ignore_file_path)
|
87 |
+
else:
|
88 |
+
ignore_list = []
|
89 |
|
90 |
+
structure, contents = process_repository(temp_dir, ignore_list)
|
91 |
+
full_output = f"### Project Directory Structure\n{structure}\n### Files Content\n{contents}"
|
92 |
|
93 |
+
st.markdown("### Output")
|
94 |
+
download_button(full_output, "repository_output.md", "Download Output as Markdown")
|
95 |
|
96 |
+
with st.expander("View Project Directory Structure"):
|
97 |
+
st.text(structure)
|
98 |
+
with st.expander("View Files Content"):
|
99 |
+
st.text(contents)
|
100 |
|
101 |
+
st.success("Process completed. Review the results above.")
|
|
|
|
|
|
|
|
|
|
|
|