tarakjc2c
commited on
Commit
·
856f7bf
1
Parent(s):
fde1958
Fix server config for HuggingFace Spaces
Browse files- app_retrieval_cached.py +11 -3
app_retrieval_cached.py
CHANGED
|
@@ -394,9 +394,17 @@ with gr.Blocks(title="Medical Document Retrieval (Cached)") as demo:
|
|
| 394 |
""")
|
| 395 |
|
| 396 |
print("\nOpening web interface...")
|
| 397 |
-
print(" Local access: http://127.0.0.1:7863")
|
| 398 |
print("=" * 70)
|
| 399 |
|
| 400 |
if __name__ == "__main__":
|
| 401 |
-
#
|
| 402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 394 |
""")
|
| 395 |
|
| 396 |
print("\nOpening web interface...")
|
|
|
|
| 397 |
print("=" * 70)
|
| 398 |
|
| 399 |
if __name__ == "__main__":
|
| 400 |
+
# Auto-detect environment: HuggingFace Spaces vs local
|
| 401 |
+
import os
|
| 402 |
+
is_spaces = os.getenv("SPACE_ID") is not None
|
| 403 |
+
|
| 404 |
+
if is_spaces:
|
| 405 |
+
# HuggingFace Spaces: listen on all interfaces, default port
|
| 406 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 407 |
+
else:
|
| 408 |
+
# Local: standard config
|
| 409 |
+
print(" Local access: http://127.0.0.1:7863")
|
| 410 |
+
demo.launch(server_name="127.0.0.1", server_port=7863)
|