Spaces:
Sleeping
Sleeping
Commit
·
e2f827f
1
Parent(s):
051c49d
test six
Browse files
serve.py
CHANGED
|
@@ -3,7 +3,18 @@ import os
|
|
| 3 |
|
| 4 |
# Configure server with host, port, and public_url
|
| 5 |
# For local testing, use localhost. For HF Spaces, use the Space URL
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
server = Server(
|
| 9 |
"python -m textual",
|
|
|
|
| 3 |
|
| 4 |
# Configure server with host, port, and public_url
|
| 5 |
# For local testing, use localhost. For HF Spaces, use the Space URL
|
| 6 |
+
space_host = os.environ.get("SPACE_HOST")
|
| 7 |
+
if space_host:
|
| 8 |
+
# HF Spaces provides the domain without protocol, so add https://
|
| 9 |
+
if not space_host.startswith(("http://", "https://")):
|
| 10 |
+
public_url = f"https://{space_host}"
|
| 11 |
+
else:
|
| 12 |
+
public_url = space_host
|
| 13 |
+
else:
|
| 14 |
+
# Default for local testing
|
| 15 |
+
public_url = "http://localhost:7860"
|
| 16 |
+
|
| 17 |
+
print(f"Using public_url: {public_url}")
|
| 18 |
|
| 19 |
server = Server(
|
| 20 |
"python -m textual",
|