![]() |
Haserl is a small program that uses shell or Lua script to create dynamic content with CGI scripts. It is intended for environments where PHP or ruby are too big. On nslu2, because of the limited RAM resource, CGI can sometimes outperform other solutions. The webif project for openwrt firmware uses haserl to build web interfaces for routers. To use haserl, you also need a web server that supports CGI. Most web servers do. Below minihttpd is used as an example. # ipkg update # ipkg install haserl minihttpd To test the dynamically generated web page, w3m text browser is used. # ipkg install w3m Make sure minihttpd is started. By default it listens on port 8084, with /opt/share/www as web root. # /opt/etc/init.d/S80mini_httpd start # test -f /opt/share/www/index.html || echo index > /opt/share/www/index.html $ w3m -dump http://localhost:8084/ index And /opt/share/www/cgi-bin is the directory to put your CGI scripts. # mkdir -p /opt/share/www/cgi-bin/ # cat <<EOF > /opt/share/www/cgi-bin/test-haserl.cgi #!/opt/bin/haserl content-type: text/plain hello world from haserl! date: <% date %> env: <% env %> EOF # chmod +x /opt/share/www/cgi-bin/test-haserl.cgi # w3m -dump http://localhost:8084/cgi-bin/test-haserl.cgi hello world from haserl! date: Thu Sep 6 19:59:56 PDT 2007 env: GATEWAY_INTERFACE=CGI/1.1 ... Both haserl without lua and with lua are built, testing a lua CGI script. # mkdir -p /opt/share/www/cgi-bin/
# cat <<EOF > /opt/share/www/cgi-bin/test-haserl-lua.cgi
#!/opt/bin/haserl-with-lua --shell=lua
content-type: text/plain
<% io.write("Hello World from Haserl and Lua on " .. os.date()) %>
EOF
# chmod +x /opt/share/www/cgi-bin/test-haserl-lua.cgi
$ w3m -dump http://localhost:8084/cgi-bin/test-haserl-lua.cgi
Hello World from Haserl and Lua on Sun Mar 23 10:26:54 2008
edit by Rudolf Reuter, reuterr (at) web.de 2008-03-05: 500 Internal Error Something unexpected went wrong running a CGI program. ттттттттттттттттттттттттттттттттттттттттттттттттттттттттттттттттттттттттттттттт mini_httpd/1.19 19dec2003 End of edit |