Spaces:
Sleeping
Sleeping
Commit
·
051c49d
1
Parent(s):
26efa1b
test five
Browse files- Dockerfile +3 -0
- serve.py +12 -2
Dockerfile
CHANGED
|
@@ -5,6 +5,9 @@ ENV TERM=xterm-256color
|
|
| 5 |
ENV COLORTERM=truecolor
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
# Install system dependencies
|
| 9 |
RUN apt-get update && apt-get install -y \
|
| 10 |
gcc \
|
|
|
|
| 5 |
ENV COLORTERM=truecolor
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
|
| 8 |
+
# HF Spaces will set SPACE_HOST automatically, but we can provide a fallback
|
| 9 |
+
ENV SPACE_HOST=${SPACE_HOST:-http://localhost:7860}
|
| 10 |
+
|
| 11 |
# Install system dependencies
|
| 12 |
RUN apt-get update && apt-get install -y \
|
| 13 |
gcc \
|
serve.py
CHANGED
|
@@ -1,5 +1,15 @@
|
|
| 1 |
from textual_serve.server import Server
|
|
|
|
| 2 |
|
| 3 |
-
# Configure server with host
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
server.serve()
|
|
|
|
| 1 |
from textual_serve.server import Server
|
| 2 |
+
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 |
+
public_url = os.environ.get("SPACE_HOST", "http://localhost:7860")
|
| 7 |
+
|
| 8 |
+
server = Server(
|
| 9 |
+
"python -m textual",
|
| 10 |
+
host="0.0.0.0",
|
| 11 |
+
port=7860,
|
| 12 |
+
public_url=public_url, # This fixes the WebSocket URL issue
|
| 13 |
+
title="Textual Demo"
|
| 14 |
+
)
|
| 15 |
server.serve()
|