Skip to content

Instantly share code, notes, and snippets.

@norman
Created January 13, 2011 15:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norman/777993 to your computer and use it in GitHub Desktop.
Save norman/777993 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/lua
require "wsapi.cgi"
require "socket"
local function sleep(n)
socket.select(nil, nil, n)
end
local function run(wsapi_env)
local headers = {["Content-type"] = "text/plain"}
local function show_counter()
for i = 1,3 do
local message = string.format("Counter is at %d\n", i)
coroutine.yield(message)
sleep(0.5)
end
end
return 200, headers, coroutine.wrap(show_counter)
end
wsapi.cgi.run(run)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment