Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,10 @@ from openai import ChatCompletion
|
|
12 |
from xml.etree import ElementTree as ET
|
13 |
from bs4 import BeautifulSoup
|
14 |
from collections import deque
|
|
|
|
|
|
|
|
|
15 |
|
16 |
openai.api_key = os.getenv('OPENAI_KEY')
|
17 |
st.set_page_config(
|
@@ -158,15 +162,30 @@ def main():
|
|
158 |
create_file(filename, user_prompt, response)
|
159 |
st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
|
160 |
|
161 |
-
all_files = glob.glob("
|
|
|
162 |
for file in all_files:
|
163 |
-
col1, col2 = st.sidebar.columns([
|
164 |
with col1:
|
165 |
st.markdown(get_table_download_link(file), unsafe_allow_html=True)
|
166 |
with col2:
|
|
|
|
|
|
|
167 |
if st.button("π", key=file):
|
168 |
os.remove(file)
|
169 |
st.experimental_rerun()
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
if __name__ == "__main__":
|
172 |
main()
|
|
|
12 |
from xml.etree import ElementTree as ET
|
13 |
from bs4 import BeautifulSoup
|
14 |
from collections import deque
|
15 |
+
from urllib.parse import quote
|
16 |
+
|
17 |
+
def get_browse_file_link(file_path):
|
18 |
+
webbrowser.open_new_tab(os.path.abspath(file_path))
|
19 |
|
20 |
openai.api_key = os.getenv('OPENAI_KEY')
|
21 |
st.set_page_config(
|
|
|
162 |
create_file(filename, user_prompt, response)
|
163 |
st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
|
164 |
|
165 |
+
all_files = glob.glob("*.*")
|
166 |
+
all_files = sorted(all_files, key=lambda x: (os.path.splitext(x)[1], x)) # sort by file type and file name
|
167 |
for file in all_files:
|
168 |
+
col1, col2, col3 = st.sidebar.columns([3,1,1]) # adjust the ratio as needed
|
169 |
with col1:
|
170 |
st.markdown(get_table_download_link(file), unsafe_allow_html=True)
|
171 |
with col2:
|
172 |
+
if st.button("π", key=file):
|
173 |
+
get_browse_file_link(file)
|
174 |
+
with col3:
|
175 |
if st.button("π", key=file):
|
176 |
os.remove(file)
|
177 |
st.experimental_rerun()
|
178 |
|
179 |
+
|
180 |
+
#all_files = glob.glob("*.txt") + glob.glob("*.htm") + glob.glob("*.md")
|
181 |
+
#for file in all_files:
|
182 |
+
# col1, col2 = st.sidebar.columns([4,1]) # adjust the ratio as needed
|
183 |
+
# with col1:
|
184 |
+
# st.markdown(get_table_download_link(file), unsafe_allow_html=True)
|
185 |
+
# with col2:
|
186 |
+
# if st.button("π", key=file):
|
187 |
+
# os.remove(file)
|
188 |
+
# st.experimental_rerun()
|
189 |
+
|
190 |
if __name__ == "__main__":
|
191 |
main()
|