Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/ws/ws
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,11 @@ Lightpanda browser, but the code is not publicly available yet.
Clone the [demo web page](https://github.com/lightpanda-io/demo) and expose the
`public/` directory locally with a web server.

We use a simple Go program to expose the files.
We use the simple Go program to expose the files in `ws/` dir.
By default it exposes the `public` dir using the `1234` port.

```go
package main

import (
"log"
"net/http"
)

func main() {
// Simple static webserver:
log.Fatal(http.ListenAndServe(":1234", http.FileServer(http.Dir(""))))
}
```console
$ go run ws/main.go
```

## Single request
Expand Down
3 changes: 3 additions & 0 deletions ws/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/lightpanda-io/demo/ws

go 1.22.1
25 changes: 25 additions & 0 deletions ws/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"fmt"
"log"
"net/http"
"os"
)

func main() {
address := os.Getenv("WS_ADDRESS")
if address == "" {
address = ":1234"
}

dir := os.Getenv("WS_DIR")
if dir == "" {
dir = "public"
}

fmt.Fprintf(os.Stderr, "expose dir: %q\nlisten: %q\n", dir, address)

// Simple static webserver:
log.Fatal(http.ListenAndServe(address, http.FileServer(http.Dir(dir))))
}