Configuration with wsapi ======================== Here we give a simple example of apache2 configuration, where many lua scripts [2] or lua pages[3] are executed in response to URL of the form: http://server/app/script.lua http://server/app/page.lp The following rather standard apache2 configuration snippet allows scripts in /www to be executed as CGIs. Note that the app script will be placed in DocumentRoot. DocumentRoot /www/ SetHandler cgi-script Options +ExecCGI Then /www/app has to be something like the following lua snippet: #!/usr/bin/lua5.1 require "wsapi.sapi" require "wsapi.cgi" CGILUA_CONF="/non-existent/" wsapi.cgi.run(wsapi.sapi.run) The CGILUA_CONF can be se to a directory path that contains a file named config.lua. For example you can define special handlers associated to particular file extensions (there are default ones for .lp and .lua files). All configuration options are described in [4]. The following sample Lua page /www/app/page.lp prints all the parameters eventually passed to the page (e.g. page.lp?foo=bar).
Lua scrips are equipotent to Lua pages, but are better suited for implementing tasks rather then pages, since it is not allowed to mix HTML and Lua code. A sample Lua script follows: cgilua.htmlheader() cgilua.print("test") Reference ========= [2]: file:///usr/share/doc/liblua5.1-cgi-dev/doc/us/manual.html#scripts [3]: file:///usr/share/doc/liblua5.1-cgi-dev/doc/us/manual.html#templates [4]: file:///usr/share/doc/liblua5.1-cgi-dev/doc/us/manual.html#config