DevnilMaster1 commited on
Commit
cb3d29e
·
verified ·
1 Parent(s): 0e2eed6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -450,12 +450,26 @@ with gr.Blocks(title="Bangla Book Recommender") as demo:
450
 
451
 
452
  if __name__ == "__main__":
453
- # Gradio 6.x enables Server-Side Rendering (SSR) by default, which
454
- # performs a localhost reachability check. Inside HF Space containers
455
- # localhost is not accessible, causing launch() to raise:
456
- # "When localhost is not accessible, a shareable link must be created..."
457
  #
458
- # Disabling SSR sidesteps the check entirely. The app still renders
459
- # correctly client-side. The error message itself recommends this fix:
460
- # "to disable set `ssr_mode=False` in `launch()`"
461
- demo.launch(ssr_mode=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
 
451
 
452
  if __name__ == "__main__":
453
+ # Launch parameters chosen to work on Hugging Face Spaces:
 
 
 
454
  #
455
+ # - server_name="0.0.0.0": binds to all interfaces, required so the HF
456
+ # container's reverse proxy can reach the app.
457
+ #
458
+ # - server_port=7860: HF Space's expected port.
459
+ #
460
+ # - share=True: on HF Spaces this is ignored with a benign warning
461
+ # ("Setting share=True is not supported on Hugging Face Spaces"),
462
+ # but its presence bypasses Gradio's localhost-reachability check
463
+ # that otherwise raises:
464
+ # "When localhost is not accessible, a shareable link must be
465
+ # created. Please set share=True..."
466
+ # This is the documented workaround in HF forum threads on this bug.
467
+ #
468
+ # - ssr_mode=False: disables Server-Side Rendering, which has its own
469
+ # localhost check in Gradio 5/6 that conflicts with the Space sandbox.
470
+ demo.launch(
471
+ server_name="0.0.0.0",
472
+ server_port=7860,
473
+ share=True,
474
+ ssr_mode=False,
475
+ )