aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-11-13 21:33:22 +0100
committermetamuffin <metamuffin@disroot.org>2024-11-13 21:33:22 +0100
commit56ee146ec901d316f32156f955ddbdeee5a7ecd7 (patch)
treed3a44281031e1f3d791825c0c4220e4176db8e69
parentc24818388fed78ec2402ee470a04d0c6752ce3dd (diff)
downloadabrechenbarkeit-56ee146ec901d316f32156f955ddbdeee5a7ecd7.tar
abrechenbarkeit-56ee146ec901d316f32156f955ddbdeee5a7ecd7.tar.bz2
abrechenbarkeit-56ee146ec901d316f32156f955ddbdeee5a7ecd7.tar.zst
export queries
-rwxr-xr-xabrechenbarkeit.lua37
1 files 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