forked from Tank/braga
37 lines
1.0 KiB
Lua
37 lines
1.0 KiB
Lua
local template = require "resty.template"
|
|
local handle = require('framework.handle')
|
|
|
|
local function resp(start,ends)
|
|
local view = template.new("index.html", "layout.html")
|
|
view.start = start
|
|
view.ends = ends
|
|
view.title = "Мои чаны"
|
|
view.cellar = {temp=12, warm=45, warm_status='is-danger',temp_status='is-warning'}
|
|
view.room = {temp=18, warm=45,warm_status='is-success',temp_status='is-warning'}
|
|
view.stat = {
|
|
{temp = 16, day = '2026-03-02'},
|
|
{temp = 17, day = '2026-03-03'},
|
|
{temp = 18, day = '2026-03-04'},
|
|
{temp = 17, day = '2026-03-05'},
|
|
{temp = 15, day = '2026-03-06'}
|
|
}
|
|
view.tank = {status = 'is-primary'}
|
|
view:render()
|
|
end
|
|
|
|
local request = {
|
|
POST = function()
|
|
ngx.req.read_body()
|
|
local args, err = ngx.req.get_post_args()
|
|
resp(string.match(args['datetimes'], "([%d-%s:]+)%s>%s([%d-%s:]+)"))
|
|
end,
|
|
GET = function()
|
|
local ends = os.date('%Y-%m-%d %H:%M:%S',os.time()+14400)
|
|
local start = os.date('%Y-%m-%d %H:%M:%S',os.time()-86400)
|
|
resp(start,ends)
|
|
end
|
|
}
|
|
|
|
ngx.say(handle(request))
|
|
|