diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index 366dc70..f02e888 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -710,13 +710,46 @@ local function extract_username() return username end +local function r_export_log() + local log = io.open("log", "r") + if log == nil then + return function() return nil end + end + print("Status: 200") + print("Content-Type: text/csv") + print("") + for l in log:lines("l") do + print(l) + end +end +local function r_export_products() + local log = io.open("products", "r") + if log == nil then + return function() return nil end + end + print("Status: 200") + print("Content-Type: text/csv") + print("") + for l in log:lines("l") do + print(l) + end +end + if path == "/" then if query.about then return r_about() elseif query.products then - return r_products() + if query.export then + return r_export_products() + else + return r_products() + end elseif query.log then - return r_log() + if query.export then + return r_export_log() + else + return r_log() + end elseif query.create_user then return r_create_user() elseif query.spus then