abraham9486937737 commited on
Commit
a77dd7c
·
1 Parent(s): 68ff299

Simplify logo loading: prioritize streamlit_app directory

Browse files
Files changed (1) hide show
  1. streamlit_app/app.py +30 -33
streamlit_app/app.py CHANGED
@@ -247,45 +247,42 @@ with st.sidebar:
247
  try:
248
  from PIL import Image
249
 
250
- logo_candidates = [
251
- Path(__file__).parent / "mypace-logo.png", # streamlit_app/mypace-logo.png
252
- Path(project_root) / "mypace-logo.png", # root/mypace-logo.png
253
- Path.cwd() / "mypace-logo.png", # cwd/mypace-logo.png
254
- ]
255
-
256
- # Add all parent directories
257
- for parent in Path(__file__).resolve().parents:
258
- logo_candidates.append(parent / "mypace-logo.png")
259
 
260
- # Try to find and load the logo
261
- logo_path = None
262
- for candidate in logo_candidates:
263
- if candidate.exists():
264
- logo_path = candidate
265
- break
266
-
267
- if logo_path:
268
- try:
269
- # Use PIL to open and display the image
 
 
 
 
 
 
 
 
270
  logo_img = Image.open(logo_path)
271
  st.image(logo_img, use_container_width=True)
272
- except Exception as e:
273
- # Fallback to string path
274
- st.image(str(logo_path), use_container_width=True)
275
- else:
276
- # File not found, try URL
277
- hf_logo_url = "https://huggingface.co/spaces/abrahamcbe/myspace-ooty-analytics/resolve/main/mypace-logo.png"
278
- try:
279
- st.image(hf_logo_url, use_container_width=True)
280
- except Exception:
281
- # Use base64 embedded image
282
  try:
283
- logo_b64 = "".join(LOGO_B64.split())
284
- st.image(f"data:image/png;base64,{logo_b64}", use_container_width=True)
285
  except Exception:
286
- st.markdown("<h1 style='text-align: center; font-size: 80px;'>🏨</h1>", unsafe_allow_html=True)
 
 
 
 
 
287
  except Exception as e:
288
- # Last resort: emoji
289
  st.markdown("<h1 style='text-align: center; font-size: 80px;'>🏨</h1>", unsafe_allow_html=True)
290
 
291
  st.title("🏨 MySpace Ooty Holiday Inn")
 
247
  try:
248
  from PIL import Image
249
 
250
+ # Try to load logo from streamlit_app directory first (most direct path)
251
+ logo_direct = Path(__file__).parent / "mypace-logo.png"
 
 
 
 
 
 
 
252
 
253
+ if logo_direct.exists():
254
+ # Load directly from streamlit_app folder
255
+ logo_img = Image.open(logo_direct)
256
+ st.image(logo_img, use_container_width=True)
257
+ else:
258
+ # Fallback: Try other paths
259
+ logo_candidates = [
260
+ Path(project_root) / "mypace-logo.png",
261
+ Path.cwd() / "mypace-logo.png",
262
+ ]
263
+
264
+ logo_path = None
265
+ for candidate in logo_candidates:
266
+ if candidate.exists():
267
+ logo_path = candidate
268
+ break
269
+
270
+ if logo_path:
271
  logo_img = Image.open(logo_path)
272
  st.image(logo_img, use_container_width=True)
273
+ else:
274
+ # Try HF URL
275
+ hf_logo_url = "https://huggingface.co/spaces/abrahamcbe/myspace-ooty-analytics/resolve/main/mypace-logo.png"
 
 
 
 
 
 
 
276
  try:
277
+ st.image(hf_logo_url, use_container_width=True)
 
278
  except Exception:
279
+ # Use base64
280
+ try:
281
+ logo_b64 = "".join(LOGO_B64.split())
282
+ st.image(f"data:image/png;base64,{logo_b64}", use_container_width=True)
283
+ except Exception:
284
+ st.markdown("<h1 style='text-align: center; font-size: 80px;'>🏨</h1>", unsafe_allow_html=True)
285
  except Exception as e:
 
286
  st.markdown("<h1 style='text-align: center; font-size: 80px;'>🏨</h1>", unsafe_allow_html=True)
287
 
288
  st.title("🏨 MySpace Ooty Holiday Inn")