require "lol"

function onRequest(env)
	params = lol:getQueryParams(env["QUERY_STRING"]);

	print("<html>\n<body>\n<head>\n <title>OSD Remote Controller</title>\n</head>\n<body>\n");

	if params and tonumber(params.channel) then
		os.execute("./channel "..tostring(tonumber(params.channel)));
		print("<b>The channel should now be "..tostring(params.channel).."</b><br/>");
	end

	print([[<form action="channel.lua" method = "get">
			<input type="text" name="channel" />
			<input type="submit" value="Select" />
		</form> ]])
	print("\n</body>\n</html>");
end
