lua-users home
lua-l archive

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



On Sep 16, 2008, at 3:18 PM, Jerome Vuarand wrote:

I'd like to write a simple application running on a webserver. It
would be run by Apache as a cgi script. Its output would naturally be
redirected to the browser that triggered the cgi execution, and I'd
like to access the http request information easily (headers, GET/POST
information).

FWIW, here is a self contained, more or less complete CGI handler implemented in Lua:

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

Superficial documentation:

http://dev.alt.textdrive.com/browser/LW/CGI.html?format=raw

Usage example:

local CGI = require( "CGI" )

print( CGI )
print( CGI:request() )
print( CGI:request():url() )
print( CGI:response() )

CGI:log()( "Arghh!", 123, nil, true )
CGI:print()( "Hello?" )
CGI:print()( "World?" )
CGI:print()( "Anyone?", "There?" )
CGI:response():write( "Hello?", "Hello?" )
CGI:response():setCookie( "hello", "world" )

print( ( "<bla> & \"oops\"" ):encode() )

CGI:run( {} )

--
PA.
http://alt.textdrive.com/nanoki/