wifi.setmode(wifi.STATIONAP)

local accessPointConfig = {}
accessPointConfig.ssid = "myhotspot" .. node.chipid()
accessPointConfig.pwd = "password"
accessPointConfig.max = 1
accessPointConfig.auth = wifi.AUTH_OPEN

wifi.ap.config(accessPointConfig)
wifi.ap.dhcp.start()

svr = net.createServer (net.TCP, 30)

svr:listen (80, function(conn)
   conn:on ("receive", function (conn, req_data)
      print("REQ DATA: " .. req_data)
      sendIndex(conn)
   end)

   conn:on ("sent", function(conn)
      conn:close ( )
   end)
end)

function sendIndex(conn)
   indexhtml_fails = 'HTTP/1.1 200 OK\n\n<!DOCTYPE HTML><html>Hello</html' --"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
   indexhtml_succeeds = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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