[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua web stuff
- From: Petite Abeille <petite.abeille@...>
- Date: Fri, 25 Jan 2008 13:35:53 +0100
On Jan 25, 2008, at 6:01 AM, Eric Tetz wrote:
I need to write a web interface to a database, and was considering Lua
('cause it's fun ^_^). A quick Google turns up Kepler, which
the website alone seems to be fairly mature.
The web part of Kepler is very much in flux at the moment...
Kepler's LuaSQL will help with database connectivity though:
Here is an example using DB.lua, a wrapper around LuaSQL:
local DB = require( 'DB' )
local aDB = DB( 'mysql://localhost/test' )
for aContact in aDB( 'select * from contact where email like %s order
by 1', 'maria%' ) do
print( aContact.name, aContact.email )
Are there any other mature ones? How robust/complete/usable are
these compared to something like PHP?
Never used PHP, so cannot comment on that, but... there are quiet a
few Web libraries around.
For example, HTTP.lua  is very similar in spirit to web.py.
Canonical 'HelloWorld.lua' example:
local HTTP = require( 'HTTP' )
HTTP[ '/hello(%a*)' ] = function( aName ) return 'Hello ' .. ( aName
or 'world' ) end
Run 'HelloWorld.lua' under tcpserver  or such:
% tcpserver 0 1080 lua HelloWorld.lua
% telnet localhost 1080
Connected to localhost.
Escape character is '^]'.
GET /hello HTTP/1.0
HTTP/1.1 200 OK
Date: Fri, 25 Jan 2008 12:25:26 GMT
Content-Type: text/html; charset=utf-8
That said... Lua is very much a 'bring your own' kind of place... in
other words... not many batteries are included out-of-the-box...
usually your best bet is to assemble the different parts you need by
yourself and get going...
"Lua gives you the power; you build the mechanisms."
-- Roberto Ierusalimschy, Programming in Lua, December 2003