Update app.py
Browse files
app.py
CHANGED
|
@@ -54,9 +54,9 @@ def download_user_page(username):
|
|
| 54 |
html_file_path = os.path.join(HTML_DIR, f"{username}.html")
|
| 55 |
with open(html_file_path, "w", encoding='utf-8') as html_file:
|
| 56 |
html_file.write(html_content)
|
| 57 |
-
return html_file_path, None
|
| 58 |
except Exception as e:
|
| 59 |
-
return None, str(e)
|
| 60 |
|
| 61 |
@st.cache_resource
|
| 62 |
def create_zip_of_files(files, zip_name):
|
|
@@ -77,17 +77,6 @@ async def fetch_all_users(usernames):
|
|
| 77 |
tasks = [fetch_user_content(username) for username in usernames]
|
| 78 |
return await asyncio.gather(*tasks)
|
| 79 |
|
| 80 |
-
def get_all_html_files(usernames):
|
| 81 |
-
html_files = []
|
| 82 |
-
errors = {}
|
| 83 |
-
for username in usernames:
|
| 84 |
-
html_file, error = download_user_page(username)
|
| 85 |
-
if html_file:
|
| 86 |
-
html_files.append(html_file)
|
| 87 |
-
else:
|
| 88 |
-
errors[username] = error
|
| 89 |
-
return html_files, errors
|
| 90 |
-
|
| 91 |
def perform_snapshot_download(repo_id, repo_type):
|
| 92 |
try:
|
| 93 |
temp_dir = tempfile.mkdtemp()
|
|
@@ -130,10 +119,14 @@ if st.button("Show User Content and Download Snapshots"):
|
|
| 130 |
models = user_data["models"]
|
| 131 |
datasets = user_data["datasets"]
|
| 132 |
|
| 133 |
-
html_file_path, download_error = download_user_page(username)
|
| 134 |
-
if html_file_path:
|
| 135 |
successful_html_files.append(html_file_path)
|
| 136 |
st.success(f"✅ Successfully downloaded {username}'s page.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
else:
|
| 138 |
st.error(f"❌ Failed to download {username}'s page: {download_error}")
|
| 139 |
|
|
@@ -217,4 +210,5 @@ st.sidebar.markdown("""
|
|
| 217 |
4. For each model or dataset, you can click the "Download Snapshot" button to download a snapshot.
|
| 218 |
5. **Download ZIP archives** containing all the HTML pages and snapshots by clicking the download links.
|
| 219 |
6. Check out the statistics visualizations below!
|
|
|
|
| 220 |
""")
|
|
|
|
| 54 |
html_file_path = os.path.join(HTML_DIR, f"{username}.html")
|
| 55 |
with open(html_file_path, "w", encoding='utf-8') as html_file:
|
| 56 |
html_file.write(html_content)
|
| 57 |
+
return html_file_path, html_content, None
|
| 58 |
except Exception as e:
|
| 59 |
+
return None, None, str(e)
|
| 60 |
|
| 61 |
@st.cache_resource
|
| 62 |
def create_zip_of_files(files, zip_name):
|
|
|
|
| 77 |
tasks = [fetch_user_content(username) for username in usernames]
|
| 78 |
return await asyncio.gather(*tasks)
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
def perform_snapshot_download(repo_id, repo_type):
|
| 81 |
try:
|
| 82 |
temp_dir = tempfile.mkdtemp()
|
|
|
|
| 119 |
models = user_data["models"]
|
| 120 |
datasets = user_data["datasets"]
|
| 121 |
|
| 122 |
+
html_file_path, html_content, download_error = download_user_page(username)
|
| 123 |
+
if html_file_path and html_content:
|
| 124 |
successful_html_files.append(html_file_path)
|
| 125 |
st.success(f"✅ Successfully downloaded {username}'s page.")
|
| 126 |
+
|
| 127 |
+
# Add expander to view HTML content
|
| 128 |
+
with st.expander(f"View {username}'s HTML page"):
|
| 129 |
+
st.markdown(html_content, unsafe_allow_html=True)
|
| 130 |
else:
|
| 131 |
st.error(f"❌ Failed to download {username}'s page: {download_error}")
|
| 132 |
|
|
|
|
| 210 |
4. For each model or dataset, you can click the "Download Snapshot" button to download a snapshot.
|
| 211 |
5. **Download ZIP archives** containing all the HTML pages and snapshots by clicking the download links.
|
| 212 |
6. Check out the statistics visualizations below!
|
| 213 |
+
7. **New feature:** You can now view the HTML content of each user's page by clicking on the expander.
|
| 214 |
""")
|