summaryrefslogtreecommitdiffstats
path: root/examples/lua/handler.lua
blob: dbcea4ab499575461e64d8230c98d0769ebd1a2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function handle_request(env)
	uhttpd.send("Status: 200 OK\r\n")
	uhttpd.send("Content-Type: text/html\r\n\r\n")

	uhttpd.send("<h1>Headers</h1>\n")
	for k, v in pairs(env.headers) do
		uhttpd.send(string.format("<strong>%s</strong>: %s<br>\n", k, v))
	end

	uhttpd.send("<h1>Environment</h1>\n")
	for k, v in pairs(env) do
		if type(v) == "string" then
			uhttpd.send(string.format("<code>%s=%s</code><br>\n", k, v))
		end
	end
end