From 56ee146ec901d316f32156f955ddbdeee5a7ecd7 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 13 Nov 2024 21:33:22 +0100 Subject: [PATCH] export queries --- abrechenbarkeit.lua | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) 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