IAMTFRMZA commited on
Commit
b1d4a6a
·
verified ·
1 Parent(s): 76091f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -220,7 +220,7 @@ with tab2:
220
  filename_matches = re.findall(r'Image Filename:\s*(.*?\.png)', st.session_state.image_response)
221
 
222
  for fname in filename_matches:
223
- # Dynamically determine folder from filename (prefix before '_page_')
224
  parts = fname.split("_page_")
225
  if len(parts) > 1:
226
  folder = parts[0]
@@ -228,11 +228,10 @@ with tab2:
228
  st.warning(f"⚠️ Could not determine folder for: {fname}")
229
  continue
230
 
231
- # Encode folder (spaces, parentheses) and filename (spaces only)
232
- encoded_folder = folder.replace(" ", "%20").replace("(", "%28").replace(")", "%29")
233
- encoded_fname = fname.replace(" ", "%20") # Leave ( ) unencoded in filename
234
 
235
- # ✅ Construct valid GitHub raw URL
236
  url = f"https://raw.githubusercontent.com/AndrewLORTech/witspathologaihisto/main/{encoded_folder}/{encoded_fname}"
237
 
238
  try:
 
220
  filename_matches = re.findall(r'Image Filename:\s*(.*?\.png)', st.session_state.image_response)
221
 
222
  for fname in filename_matches:
223
+ # Extract folder from filename prefix (before _page_)
224
  parts = fname.split("_page_")
225
  if len(parts) > 1:
226
  folder = parts[0]
 
228
  st.warning(f"⚠️ Could not determine folder for: {fname}")
229
  continue
230
 
231
+ # Only encode spaces — leave parentheses untouched to match GitHub structure
232
+ encoded_folder = folder.replace(" ", "%20")
233
+ encoded_fname = fname.replace(" ", "%20")
234
 
 
235
  url = f"https://raw.githubusercontent.com/AndrewLORTech/witspathologaihisto/main/{encoded_folder}/{encoded_fname}"
236
 
237
  try: