davanstrien's picture
davanstrien HF Staff
test six
e2f827f
raw
history blame contribute delete
750 Bytes
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()