yum install make gcc readline-devel
lua
curl -R -O http://www.lua.org/ftp/lua-5.4.3.tar.gz
tar zxf lua-5.4.3.tar.gz
cd lua-5.4.3
make all test
make linux install
ln -s /usr/local/bin/lua /usr/bin/lua
luarocks
wget https://luarocks.org/releases/luarocks-3.7.0.tar.gz
tar zxpf luarocks-3.7.0.tar.gz
cd luarocks-3.7.0
./configure && make && sudo make install
sudo luarocks install luasocket
on rpi
sudo apt install lua-socket luarocks
wget http://download.savannah.gnu.org/releases/lzip/lzlib/lzlib-1.12.tar.gz
tar -xf lzlib-1.12.tar.gz
cd lzlib-1.12
./configure && make all check
make install
make install-bin install-man
luarocks 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)