davanstrien HF Staff commited on
Commit
3c75a0a
·
1 Parent(s): dcc9dbd

Update Dockerfile and README for Textual Calculator; add serve.py

Browse files
Files changed (3) hide show
  1. Dockerfile +2 -4
  2. README.md +37 -3
  3. serve.py +4 -0
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM python:3.10-slim
2
 
3
  # Set proper terminal environment for Textual
4
  ENV TERM=xterm-256color
@@ -18,9 +18,7 @@ COPY requirements.txt .
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
  # Copy application files
21
- COPY app.py .
22
- COPY calculator.py .
23
- COPY calculator.tcss .
24
 
25
  # Expose the port that HF Spaces expects
26
  EXPOSE 7860
 
1
+ FROM python:3.13-slim
2
 
3
  # Set proper terminal environment for Textual
4
  ENV TERM=xterm-256color
 
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
  # Copy application files
21
+ COPY server.py .
 
 
22
 
23
  # Expose the port that HF Spaces expects
24
  EXPOSE 7860
README.md CHANGED
@@ -1,10 +1,44 @@
1
  ---
2
- title: Textual Serve
3
- emoji:
4
  colorFrom: indigo
5
  colorTo: gray
6
  sdk: docker
 
7
  pinned: false
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Textual Calculator
3
+ emoji: 🧮
4
  colorFrom: indigo
5
  colorTo: gray
6
  sdk: docker
7
+ app_port: 7860
8
  pinned: false
9
  ---
10
 
11
+ # Textual Calculator on Hugging Face Spaces
12
+
13
+ This Space demonstrates a fully functional calculator application built with [Textual](https://github.com/Textualize/textual) and served through [textual-serve](https://github.com/Textualize/textual-serve) on Hugging Face Spaces.
14
+
15
+ ## What is this?
16
+
17
+ This Space runs a macOS-inspired calculator application as a Terminal User Interface (TUI) in your web browser. It showcases how sophisticated TUI applications can be deployed as web apps using Textual and Hugging Face Spaces.
18
+
19
+ ## Calculator Features
20
+
21
+ - 🔢 Full arithmetic operations (addition, subtraction, multiplication, division)
22
+ - % Percentage calculations
23
+ - ± Sign toggling
24
+ - 🖱️ Click buttons with your mouse
25
+ - ⌨️ Use your keyboard for input
26
+ - 🎨 Beautiful macOS-inspired design
27
+ - 🚀 Real-time interaction via WebSockets
28
+
29
+ ## How it works
30
+
31
+ 1. The Docker container runs a textual-serve server on port 7860
32
+ 2. The server spawns the Textual demo application as a subprocess
33
+ 3. WebSocket connections handle bidirectional communication
34
+ 4. Your browser displays the terminal interface
35
+
36
+ ## Want to deploy your own Textual app?
37
+
38
+ Check out the [source code](https://huggingface.co/spaces/[your-username]/textual-serve/tree/main) to see how this Space is configured and adapt it for your own Textual applications!
39
+
40
+ ## Resources
41
+
42
+ - [Textual Documentation](https://textual.textualize.io/)
43
+ - [Textual-Serve GitHub](https://github.com/Textualize/textual-serve)
44
+ - [HF Spaces Docker SDK](https://huggingface.co/docs/hub/spaces-sdks-docker)
serve.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from textual_serve.server import Server
2
+
3
+ server = Server("python -m textual")
4
+ server.serve()