Simple demo of Patch Seq on The Skyscape
A simple HTTP server written in Seq, a concatenative stack-based programming language.
Seq is a stack-based language with:
make run
Then visit http://localhost:5000
| Route | Description |
|---|---|
GET / |
Home page (static HTML) |
GET /health |
Health check |
GET /api/status |
JSON status |
GET /echo/:msg |
Echo message back |
make build # Build Docker image
make run # Run in background
make run-fg # Run in foreground
make stop # Stop container
make logs # View logs
make restart # Rebuild and restart
make test # Test endpoints
make clean # Remove image
seq-demo/
├── main.seq # Seq HTTP server source
├── static/
│ ├── index.html # Home page
│ └── 404.html # Not found page
├── Dockerfile # Multi-stage build
└── Makefile # Build commands
The server uses Seq's native TCP primitives:
: main ( -- )
8080 tcp-listen # Listen on port
accept-loop # Accept connections
;
: accept-loop ( Int -- )
dup tcp-accept # Accept connection
make-channel # Create channel for worker
dup [ worker ] spawn # Spawn green thread
drop drop send # Send connection to worker
accept-loop # Tail-recursive loop
;
Static files are loaded with file-slurp:
: serve-index ( -- String )
"static/index.html" file-slurp http-html
;
┌─────────────────────────────────────┐
│ Docker Container │
│ │
│ ┌─────────┐ ┌─────────────┐ │
│ │ socat │──────▶│ seq-demo │ │
│ │ :5000 │ │ :8080 │ │
│ └─────────┘ └─────────────┘ │
│ ▲ │
└───────│─────────────────────────────┘
│
External traffic
socat forwards external port 5000 to internal port 8080
(seq tcp-listen binds to localhost only)
MIT