-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.lua
More file actions
18 lines (18 loc) · 782 Bytes
/
app.lua
File metadata and controls
18 lines (18 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function onRequestFinish(client)
local content = {}
table.insert(content, "<!DOCTYPE html><html><head></head><body>")
table.insert(content, "<h1>Request Info</h1>")
for k, v in pairs(client.request) do
table.insert(content, "<div>" .. k .. ": " .. tostring(v) .. "</div>")
end
table.insert(content, "<hr/>")
for k, v in pairs(client.request.headers) do
table.insert(content, "<div>" .. k .. ": " .. v .. "</div>")
end
table.insert(content, "</body></html>")
content = table.concat(content)
client.response:writeVersion(client.request.versionMajor, client.request.versionMinor)
client.response:writeStatusCode(200)
client.response:writeHeader("Content-Type", "text/html")
client.response:writeBody(content)
end