lua-users home
lua-l archive

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


Hello,

In the tradition of Web.py [1], here is a Lua incarnation of its URL handling [2].

Notorious "Hello world" example:

local aFunction = function( aName )
        print( "Hello ", aName, "!" )
end

local someMappings = { "/(.*)", aFunction }

Web:start( someMappings )

http://localhost:1080/Earthling

> Hello Earthling!

Web:start() takes an orderer table of pattern/handler pairs.

The pattern captures, if any, are passed to the handler as arguments.

An handler can be either a function, a class name or a class. If the handler is a function, it's invoked without further ado. In the case of a class, the relevant method is looked up and then invoked (e.g. GET -> get() ).

http://dev.alt.textdrive.com/browser/LW/Web.lua

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/

[1] http://webpy.org/
[2] http://webpy.org/tutorial