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.

41 lines
871 B

#!/usr/bin/env lua
local fcgi = require"fcgi"
local etlua = require"etlua"
apps = {
yqtemplate = require"yqtemplate"
}
local template = etlua.compile[[
<!DOCTYPE html>
<html>
<head>
<title>Annwan's CGI scripts</title>
</head>
<body>
<% if app and app ~= "" then %>
<p>No such application: <b><%= app -%></b></p>
<% end %>
<h1>Available Applications</h1>
<ul>
<% for name, appdata in pairs(apps) do %>
<li><a href=/cgi/<%= name -%>><%=name -%></a>: <%= appdata.desc -%></li>
<% end %>
</ul>
</body>
</html>
]]
while fcgi.accept() do
app = fcgi.getenv("DOCUMENT_URI"):sub(6)
appfn = apps[app]
if appfn then
appfn.run(fcgi)
else
fcgi.print"Content-Type: text/html; charset=utf-8\r\n\r\n"
fcgi.print(template{
app = app,
apps = apps
})
end
end