Skip to content

Instantly share code, notes, and snippets.

@cablehead
Created February 21, 2017 21:53
Show Gist options
  • Save cablehead/fd6944c666bc3f38a6a8f281c767761e to your computer and use it in GitHub Desktop.
Save cablehead/fd6944c666bc3f38a6a8f281c767761e to your computer and use it in GitHub Desktop.
local levee = require("levee")
local fsource = require('levix.source.file')
local h = levee.Hub()
local err, sources = fsource.watch(h, "./sources.json")
print(err, sources)
local function serve(h)
local err, serve = h.http:listen(9999)
for conn in serve do
h:spawn(function()
while true do
local err, req = conn:recv()
if err then
conn:close()
return
end
print(req.path)
req.response:send({levee.HTTPStatus(200), {}, "Hello world\n"})
end
end)
end
end
serve(h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment