-
-
Save katlogic/9b0c43cbb1ab1e00df91 to your computer and use it in GitHub Desktop.
Prototyping lua-http server api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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