tech-userlevel archive

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

Re: Dynamic content with bozohttpd



Am 11.10.13 20:35, schrieb Jochen Kunz:
> On Fri, 11 Oct 2013 13:31:29 +0200
> Marc Balmer <marc%msys.ch@localhost> wrote:
> 
>> Comments welcome.
> I really like it. It makes it easy to build some small HTTP driven
> alliances entirely with tools from base.
> 
> Take somthing like a Raspberry Pi, Beaglebone(Black), Olinuxino, ...,
> connect it to your home network, connect somthing like the room lights,
> the heating, temperature sensors, power meters, ... to the gpio(4) pins
> of the thing, hack a litle Lua script to glue httpd(8) to the lua
> binding of gpio(4) and you can control it from your desktop machine or
> smart phone via a simple web interface.
> 
> How to get POST data from within a Lua handler?
> 
> What about PATH_INFO when GETing
> http://<hostname>/rest/printenv/foo/bar


Keep one thing in mind:  bozohttpd forks for each request when in daemon
mode, so you can't keep any state between calls, other maybe than using
a cookie and look up stuff in a database (sqlite) using the cookie as
the key.

The main advantage is that the Lua code get's compiled when the server
starts and when a request comes in, it can directly be called, which is
very fast.  You can setup some variables in the Lua script, just they
will have the same value for each invocation.  So you might store
database credentials from a config file in your Lua script at startup,
but you have to reconnect to the database for each request.

If that is to limiting, use a webserver with FastCGI and the Lua FastCGI
binding on github.com/mbalmer.





Home | Main Index | Thread Index | Old Index