Left here for archival purposes.

User avatar
By Pram
#11277
MK1888 wrote:Lesson #1 in troubleshooting: Start with the simplest configuration that works and then move up in complexity.

You have a bunch of things going on. Get a very simple webserver working first. Can you serve HTML to your Safari browser? Like this: <html><body><h1>blah</h1></body></html>

Then add things one at a time until it breaks.

EDIT: By the way...the HTML that you are producing in your last post is not valid. You can't start an HTML page with <font>.


So now I just tried <html><body><h1>blah</h1></body></html>, but Safari could noct open it. I also edited my code and put in <html><body> at the beginning and </body></html> at the end.
User avatar
By MK1888
#11316 Simple web server:

Code: Select allwifi.ap.config({ssid="NODEDUINO",pwd=""})
wifi.setmode(wifi.SOFTAP)

if srv then
   srv:close()
end
srv=net.createServer(net.TCP,30)
srv:listen(80,function(conn)
   conn:on("receive",function(conn, payload)
      print(payload)
      if string.sub(payload, 1, 6) == 'GET / ' then
         conn:send("HTTP/1.1 200 OK\r\n")
         conn:send("<html><body><h1>ESP8266 Web Server</h1></body></html>")
      end
   end)
   conn:on("sent",function(conn)
      conn:close()
   end)
end)
Last edited by MK1888 on Tue Mar 10, 2015 12:08 pm, edited 1 time in total.