Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
d5529846
Commit
d5529846
authored
Jun 16, 2016
by
Marcel Stör
Browse files
Fix the HTTP server examples
parent
d445ae97
Changes
2
Show whitespace changes
Inline
Side-by-side
README.md
View file @
d5529846
...
@@ -30,7 +30,7 @@ srv = net.createServer(net.TCP)
...
@@ -30,7 +30,7 @@ srv = net.createServer(net.TCP)
srv
:
listen
(
80
,
function
(
conn
)
srv
:
listen
(
80
,
function
(
conn
)
conn
:
on
(
"receive"
,
function
(
sck
,
payload
)
conn
:
on
(
"receive"
,
function
(
sck
,
payload
)
print
(
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
)
end
)
conn
:
on
(
"sent"
,
function
(
sck
)
sck
:
close
()
end
)
conn
:
on
(
"sent"
,
function
(
sck
)
sck
:
close
()
end
)
end
)
end
)
...
...
docs/en/index.md
View file @
d5529846
...
@@ -11,11 +11,11 @@ The NodeMCU programming model is similar to that of [Node.js](https://en.wikiped
...
@@ -11,11 +11,11 @@ The NodeMCU programming model is similar to that of [Node.js](https://en.wikiped
-- a simple HTTP server
-- a simple HTTP server
srv
=
net
.
createServer
(
net
.
TCP
)
srv
=
net
.
createServer
(
net
.
TCP
)
srv
:
listen
(
80
,
function
(
conn
)
srv
:
listen
(
80
,
function
(
conn
)
conn
:
on
(
"receive"
,
function
(
conn
,
payload
)
conn
:
on
(
"receive"
,
function
(
sck
,
payload
)
print
(
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
)
end
)
conn
:
on
(
"sent"
,
function
(
conn
)
conn
:
close
()
end
)
conn
:
on
(
"sent"
,
function
(
sck
)
sck
:
close
()
end
)
end
)
end
)
```
```
```
lua
```
lua
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment