<% -- @author evenS local act = luci.http.formvalue('act') local json = '' %> <% action = { ['on'] = function() luci.sys.exec('echo -en "ledon" > /dev/ttyUSB0') json = "灯亮了" end, ['off'] = function() luci.sys.exec('echo -en "ledof" > /dev/ttyUSB0') json = "灯灭了" end } if action[act] then action[act]() else json = '{"state": 0, "msg": "不支持的命令"}' end print(json) %>