DevnilMaster1 commited on
Commit
fa4b1c8
Β·
verified Β·
1 Parent(s): 1c70e81

Disable SSR mode to fix localhost check on HF Space

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -449,15 +449,13 @@ with gr.Blocks(title="Bangla Book Recommender") as demo:
449
  )
450
 
451
 
452
- # ─────────────────────────────────────────────────────────────────────────────
453
- # Note: We deliberately do NOT call demo.launch() here.
454
- #
455
- # On Hugging Face Spaces with Gradio 6.x, the platform's runtime spawns the
456
- # server itself by importing this module and serving the `demo` object.
457
- # Calling .launch() ourselves triggers a localhost-reachability check that
458
- # fails inside the Space's container, raising:
459
- # "When localhost is not accessible, a shareable link must be created..."
460
- #
461
- # For local development, run: `gradio app.py` (which calls launch() for you)
462
- # or add `demo.launch()` back temporarily.
463
- # ─────────────────────────────────────────────────────────────────────────────
 
449
  )
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)