ual.lua 567 B

12345678910111213141516171819202122232425
  1. local function storelist(table)
  2. file.remove("http/aplist.json")
  3. file.open("http/aplist.json","w")
  4. coroutine.yield()
  5. file.write(cjson.encode(table))
  6. file.close()
  7. print(cjson.encode(table))
  8. end
  9. local function sendHeader(connection)
  10. connection:send("HTTP/1.0 200 OK\r\nContent-Type: application/json\r\nCache-Control: private, no-store\r\n\r\n")
  11. connection:send('{"error":0, "message":"OK"}')
  12. end
  13. return function(connection,args)
  14. sendHeader(connection)
  15. wifi.sta.getap(storelist)
  16. end