lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I've had a look at Kepler, CGILua and WSAPI, but none of them explains
> how to run simple Lua cgi applications from Apache.

Here is the method I prefer, using WSAPI with request and response objects:

#! /bin/bash /path/to/kepler/bin/wsapi.cgi
require("wsapi.request")
require("wsapi.response")
return function (env)
  local request = wsapi.request.new(env)
  local response = wsapi.response.new()
  response:write("<h1>Hello</h1>")
  for k,v in pairs(request.GET) do
     response:write(k.." = "..tostring(v).."<br/>")
  end
  return response:finish()
end

Put this into hello.cgi in where you would put other CGI files, set
the standard CGI permissions and access it like any CGI file.  The
fact that the body of the script is wrapped in a function may be a
hassle for simple CGI, but the plus is that it allows you to use the
exact same script with Xavante (just rename it hello.ws and put it in
kepler/htdocs).

- yuri

-- 
http://sputnik.freewisdom.org/