File size: 750 Bytes
3c75a0a
051c49d
3c75a0a
051c49d
 
e2f827f
 
 
 
 
 
 
 
 
 
 
 
051c49d
 
 
 
 
 
 
 
26efa1b
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 -m textual",
    host="0.0.0.0",
    port=7860,
    public_url=public_url,  # This fixes the WebSocket URL issue
    title="Textual Demo"
)
server.serve()