local function gen_page(data)
local s=data.param
if (data.key) then
local c=data.type
if (c == 'boolean') then c='option true;false' end
if (c:sub(1,7) == 'option ') then
send_buffered("")
else
send_buffered(" ")
end
s.sep='
'
else
if (s.output) then
if (s.sep ~= '') then
send_buffered(s.sep)
s.sep=''
end
local text
local prefix=''
local postfix=' '
if (data.line:sub(1,6) == '------') then
prefix='
'
text=data.line:sub(7)
postfix='
'
elseif (data.line:sub(1,4) == '----') then
prefix='
'
text=data.line:sub(5)
postfix='
'
else
text=data.line:sub(4)
end
send_buffered(prefix..text..postfix)
end
if (data.line == '-- BEGIN') then
s.output=true
end
end
return true
end
return function (info)
if (not authenticated()) then
return
end
send_buffered(info.http_preamble)
if (info.headers.method == 'POST') then
if (config.update(info.postdata)) then
send_buffered("Your new configuration has been stored in flash. You have to reboot the system in order to run with the new settings. Reboot now! Back to main page",nil)
return
else
send_buffered('An error occured')
end
end
send_buffered("FF-ESP32 irrigation configuration")
end