You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
803 B

  1. #!/usr/bin/env lua
  2. local fcgi = require"fcgi"
  3. apps = {
  4. yqtemplate = require"yqtemplate"
  5. }
  6. while fcgi.accept() do
  7. app = fcgi.getenv("DOCUMENT_URI"):sub(6)
  8. appfn = apps[app]
  9. if appfn then
  10. appfn.run(fcgi)
  11. else
  12. fcgi.print"Content-Type: text/html; charset=utf-8\r\n\r\n"
  13. fcgi.print[[<!DOCTYPE html>
  14. <html>
  15. <head><title>Annwan's CGI scripts</title></head>
  16. <body>]]
  17. if app and app ~= "" then
  18. fcgi.print("<p>No such application application: <b>" .. app .. "</b></p̬>\n")
  19. end
  20. fcgi.print("<p>Available applications:</p><ul>")
  21. for n, x in pairs(apps) do
  22. fcgi.print("<li><b><a href=/cgi/" .. n .. ">" .. n .. "</a></b> " .. x.desc .. "</li>")
  23. end
  24. fcgi.print[[
  25. </ul>
  26. </body>
  27. </html>]]
  28. end
  29. end