Update app.py
Browse files
app.py
CHANGED
|
@@ -450,12 +450,26 @@ with gr.Blocks(title="Bangla Book Recommender") as demo:
|
|
| 450 |
|
| 451 |
|
| 452 |
if __name__ == "__main__":
|
| 453 |
-
#
|
| 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 |
-
#
|
| 459 |
-
#
|
| 460 |
-
#
|
| 461 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
)
|