Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/support/bobot_server/butia/butia_http.lua
blob: 6a0b1ffe9e9cd3d89d2bdf88759f9c64f62f1df7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module(..., package.seeall);

--local devices=devices
local process = require("bobot-server-process").process
local util = require("http-util")

local parse_params = util.parse_params
local load_template = util.load_file

local butia_template=load_template('butia/butia.htm') or "Error loading template butia.htm"
local header_template=load_template('butia/header.htm') or "Error loading template header.htm"

function init (get_page)
	get_page["/butia.htm"] = function (p)
		local params=parse_params(p)
		local rep = {
			['DATA1'] = params['campo'],
			['DATA2'] = tostring(params['unboton'])..', '..tostring(params['otroboton']),
		}
		local page=string.gsub(butia_template, '<!%-%-(%w+)%-%->', rep)
		return "HTTP/1.1 200/OK\r\nContent-Type:text/html\r\nContent-Length: "..#page.."\r\n\r\n"..page
	end

	get_page["/header.htm"] = function (p)
		local params=parse_params(p)
		local rep = {
		}
		local page=string.gsub(header_template, '<!%-%-(%w+)%-%->', rep)
		return "HTTP/1.1 200/OK\r\nContent-Type:text/html\r\nContent-Length: "..#page.."\r\n\r\n"..page
	end

end