From f0f14068f34adb6c9145e1c58786f2f9c805e4ee Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 23 Nov 2021 19:21:58 +0100 Subject: [PATCH] examples: add example Lua handler script Signed-off-by: Jo-Philipp Wich --- examples/lua/handler.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 examples/lua/handler.lua diff --git a/examples/lua/handler.lua b/examples/lua/handler.lua new file mode 100644 index 0000000..dbcea4a --- /dev/null +++ b/examples/lua/handler.lua @@ -0,0 +1,16 @@ +function handle_request(env) + uhttpd.send("Status: 200 OK\r\n") + uhttpd.send("Content-Type: text/html\r\n\r\n") + + uhttpd.send("

Headers

\n") + for k, v in pairs(env.headers) do + uhttpd.send(string.format("%s: %s
\n", k, v)) + end + + uhttpd.send("

Environment

\n") + for k, v in pairs(env) do + if type(v) == "string" then + uhttpd.send(string.format("%s=%s
\n", k, v)) + end + end +end -- 2.30.2