Fix the HTTP server examples

This commit is contained in:
Marcel Stör 2016-06-16 08:40:50 +02:00
parent d445ae97fb
commit d5529846f2
2 changed files with 4 additions and 4 deletions

View File

@ -30,7 +30,7 @@ srv = net.createServer(net.TCP)
srv:listen(80, function(conn)
conn:on("receive", function(sck, payload)
print(payload)
sck:send("<h1> Hello, NodeMCU.</h1>")
sck:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n<h1> Hello, NodeMCU.</h1>")
end)
conn:on("sent", function(sck) sck:close() end)
end)

View File

@ -11,11 +11,11 @@ The NodeMCU programming model is similar to that of [Node.js](https://en.wikiped
-- a simple HTTP server
srv = net.createServer(net.TCP)
srv:listen(80, function(conn)
conn:on("receive", function(conn, payload)
conn:on("receive", function(sck, payload)
print(payload)
conn:send("<h1> Hello, NodeMCU.</h1>")
sck:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n<h1> Hello, NodeMCU.</h1>")
end)
conn:on("sent", function(conn) conn:close() end)
conn:on("sent", function(sck) sck:close() end)
end)
```
```lua