Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ and can connect to various MCP servers for enhanced functionality.
|
|
| 5 |
"""
|
| 6 |
import logging
|
| 7 |
import os
|
|
|
|
| 8 |
|
| 9 |
from config import AppConfig
|
| 10 |
from mcp_client import UniversalMCPClient
|
|
@@ -35,11 +36,28 @@ def main():
|
|
| 35 |
demo = ui_components.create_interface()
|
| 36 |
|
| 37 |
# Launch the application
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
demo.launch(
|
| 39 |
debug=AppConfig.DEBUG_MODE,
|
| 40 |
share=False, # Set to True if you want to create a public link
|
| 41 |
-
server_name=
|
| 42 |
-
server_port=
|
| 43 |
auth=None, # No authentication (handled by HF login)
|
| 44 |
max_threads=40 # Allow multiple concurrent users
|
| 45 |
)
|
|
|
|
| 5 |
"""
|
| 6 |
import logging
|
| 7 |
import os
|
| 8 |
+
import socket
|
| 9 |
|
| 10 |
from config import AppConfig
|
| 11 |
from mcp_client import UniversalMCPClient
|
|
|
|
| 36 |
demo = ui_components.create_interface()
|
| 37 |
|
| 38 |
# Launch the application
|
| 39 |
+
# Prefer localhost by default. Allow override via env GRADIO_SERVER_NAME or AppConfig.GRADIO_SERVER_NAME
|
| 40 |
+
server_name = os.getenv("GRADIO_SERVER_NAME", getattr(AppConfig, "GRADIO_SERVER_NAME", "localhost"))
|
| 41 |
+
server_port = int(os.getenv("GRADIO_SERVER_PORT", str(getattr(AppConfig, "GRADIO_SERVER_PORT", 7860))))
|
| 42 |
+
|
| 43 |
+
# Log a friendly URL for quick access
|
| 44 |
+
if server_name in ("0.0.0.0", "::"):
|
| 45 |
+
local_url = f"http://localhost:{server_port}"
|
| 46 |
+
try:
|
| 47 |
+
host_ip = socket.gethostbyname(socket.gethostname())
|
| 48 |
+
except Exception:
|
| 49 |
+
host_ip = "<your-ip>"
|
| 50 |
+
lan_url = f"http://{host_ip}:{server_port}"
|
| 51 |
+
logger.info(f"🔗 Local URL: {local_url}")
|
| 52 |
+
logger.info(f"🔗 Network URL: {lan_url}")
|
| 53 |
+
else:
|
| 54 |
+
logger.info(f"🔗 URL: http://{server_name}:{server_port}")
|
| 55 |
+
|
| 56 |
demo.launch(
|
| 57 |
debug=AppConfig.DEBUG_MODE,
|
| 58 |
share=False, # Set to True if you want to create a public link
|
| 59 |
+
server_name=server_name, # Default to localhost; can be set to 0.0.0.0 if needed
|
| 60 |
+
server_port=server_port, # Default Gradio port
|
| 61 |
auth=None, # No authentication (handled by HF login)
|
| 62 |
max_threads=40 # Allow multiple concurrent users
|
| 63 |
)
|