Browse Source

[Dispatch] added application descriptions

main
Annwan 4 months ago
parent
commit
7fad9fd4f6
  1. 16
      main.lua
  2. 7
      yqtemplate.lua

16
main.lua

@ -1,15 +1,21 @@
#!/usr/bin/env lua #!/usr/bin/env lua
local fcgi = require"fcgi" local fcgi = require"fcgi"
local app_yqtemplate = require"yqtemplate"
apps = {
yqtemplate = require"yqtemplate"
}
while fcgi.accept() do while fcgi.accept() do
app = fcgi.getenv("DOCUMENT_URI"):sub(6) app = fcgi.getenv("DOCUMENT_URI"):sub(6)
if app == "yqtemplate" then
app_yqtemplate(fcgi)
appfn = apps[app]
if appfn then
appfn.run(fcgi)
else else
fcgi.print"Content-Type: text/plain; charset=utf-8\r\n\r\n" fcgi.print"Content-Type: text/plain; charset=utf-8\r\n\r\n"
fcgi.print("Unknown CGI application: `" .. app .. "'\n")
fcgi.print("No such application application: `" .. app .. "'\n")
fcgi.print("Available applications:\n")
for n, x in pairs(apps) do
fcgi.print(" - " .. n .. ": " .. x.desc .. "\n")
end
end end
end end

7
yqtemplate.lua

@ -1,4 +1,7 @@
return function(fcgi)
return {
desc = "Creates Yokoka’s quest-style personal status page",
run = function(fcgi)
fcgi.print("Content-Type: text/plain; charset=utf-8\r\n\r\n") fcgi.print("Content-Type: text/plain; charset=utf-8\r\n\r\n")
fcgi.print("Hello from application `YQTemplate'") fcgi.print("Hello from application `YQTemplate'")
end
end
}
Loading…
Cancel
Save