Disable SSR mode to fix localhost check on HF Space
Browse files
app.py
CHANGED
|
@@ -449,15 +449,13 @@ with gr.Blocks(title="Bangla Book Recommender") as demo:
|
|
| 449 |
)
|
| 450 |
|
| 451 |
|
| 452 |
-
|
| 453 |
-
#
|
| 454 |
-
#
|
| 455 |
-
#
|
| 456 |
-
#
|
| 457 |
-
#
|
| 458 |
-
#
|
| 459 |
-
#
|
| 460 |
-
#
|
| 461 |
-
|
| 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)
|
|
|
|
|
|