Skip to content

Instantly share code, notes, and snippets.

@cablehead
Last active December 5, 2015 00:42
Show Gist options
  • Save cablehead/fd87782ba5d463ec77a0 to your computer and use it in GitHub Desktop.
Save cablehead/fd87782ba5d463ec77a0 to your computer and use it in GitHub Desktop.
levee build -e '
local levee = require("levee")
h = levee.Hub()
local err, serve = h.tcp:listen(8080)
for conn in serve do
local msg = "Hello World"
conn:write("HTTP/1.1 200 OK\n")
conn:write("Server: Swift Web Server\n")
conn:write(("Content-length: %d\n"):format(#msg))
conn:write("Content-type: text-plain\n")
conn:write("\r\n")
conn:write(msg)
conn:close()
end' -o hello && ./hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment