Fast HTTP server that supports handlers written in Starlark.
Pronounced as "jetlark", just to keep people on their toes.
gnetlark
offers an easy and fun way to try out the Starlark programming language.Quick installation of the development version, using Go 1.17 or later:
go install github.com/xyproto/gnetlark/cmd/gnetlark@latest
Another way of building and installing the server:
git clone https://github.com/xyproto/gnetlark
cd gnetlark/cmd/gnetlark
go build
sudo install -Dm755 gnetlark /usr/bin/gnetlark
One way to allow access to port 80 on Linux:
sudo setcap cap_net_bind_service=+ep /usr/bin/gnetlark
It's also possible to specify a port with --port
or run it as root (not recommended).
Screenshot of a page served by index.star
, with the server running on port 7711
:
Served in 0ms:
A short Starlark script for handling requests and outputting "Hello, World!" (hello.star
):
def index(status, msg, method, path, date):
return "HTTP/1.1 " + status + "\r\nServer: gnetlark\r\nDate: " + date + "\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n" + "Hello, World!"
The "Hello World" page can be served by a command like this:
gnetlark -main hello.star -port 7711