Skip to content

Instantly share code, notes, and snippets.

@katlogic
Forked from daurnimator/server_hello.lua
Last active March 1, 2016 12:10
Show Gist options
  • Save katlogic/9b0c43cbb1ab1e00df91 to your computer and use it in GitHub Desktop.
Save katlogic/9b0c43cbb1ab1e00df91 to your computer and use it in GitHub Desktop.
Prototyping lua-http server api
require('lazyserver')(8000, {
-- note that query string is not considered in the pattern
["^/(.*)"] = function(self, cap1)
self.content_type = 'text/plain'
self:write('halo halo, you requested '+self.url[1]+', pattern captured '+cap1+', args supplied '+self.param)
return 200
end)
}
-- for even more lazy:
require('lazyserver')(8000, function(self)
-- GET /?param=1&write=2
self.content_type = 'text/plain'
self:write('halo halo, you requested '+self.url+' supplied '+arg.param)
return 200
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment