File size: 776 Bytes
3c75a0a
d55d2ce
3c75a0a
d55d2ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344f184
d55d2ce
 
 
344f184
d55d2ce
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from textual_serve.server import Server
import os

# Configure server with host, port, and public_url
# For local testing, use localhost. For HF Spaces, use the Space URL
space_host = os.environ.get("SPACE_HOST")
if space_host:
    # HF Spaces provides the domain without protocol, so add https://
    if not space_host.startswith(("http://", "https://")):
        public_url = f"https://{space_host}"
    else:
        public_url = space_host
else:
    # Default for local testing
    public_url = "http://localhost:7860"

print(f"Using public_url: {public_url}")

server = Server(
    "python textual-app/dictionary.py",
    host="0.0.0.0",
    port=7860,
    public_url=public_url,  # This fixes the WebSocket URL issue
    title="Textual Dictionary App",
)
server.serve()