yum install make gcc readline-devel
lua
curl -R -O http://www.lua.org/ftp/lua-5.4.3.tar.gztar zxf lua-5.4.3.tar.gzcd lua-5.4.3make all testmake linux installln -s /usr/local/bin/lua /usr/bin/lua
luarocks
wget https://luarocks.org/releases/luarocks-3.7.0.tar.gztar zxpf luarocks-3.7.0.tar.gzcd luarocks-3.7.0./configure && make && sudo make installsudo luarocks install luasocket
on rpi
sudo apt install lua-socket luarockswget http://download.savannah.gnu.org/releases/lzip/lzlib/lzlib-1.12.tar.gztar -xf lzlib-1.12.tar.gzcd lzlib-1.12./configure && make all checkmake installmake install-bin install-manluarocks install pegasus
http://evandrolg.github.io/pegasus.lua/
#!/usr/bin/lua
local pegasus = require "pegasus"
local server = pegasus:new({
port='9090',
location='example/root'
})
local printTable = function(table)
for k, v in pairs(table) do
print(k, '=', v)
end
end
server:start(function (request, response)
local method = request:method()
local data = request:post()
if data then
printTable(data)
end
if method == "GET" then
response:write("hi")
end
if method == "POST" then
response:write("api")
end
end)
