Skip to content

Commit 0e596ed

Browse files
substacksubstack
substack
authored and
substack
committed
simple http server
1 parent 4ed592d commit 0e596ed

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

node/simple-http-server/server.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var http = require('http')
2+
var server = http.createServer(function (req, res) {
3+
console.log(req.method, req.url)
4+
if (req.method === 'GET' && req.url === '/') {
5+
res.setHeader('content-type', 'text/html')
6+
res.end('<h1>HOWDY</h1>\n')
7+
} else {
8+
res.statusCode = 404
9+
res.setHeader('content-type', 'text/plain')
10+
res.end('not found\n')
11+
}
12+
})
13+
server.listen(3000)

node/client.js node/tcp/client.js

File renamed without changes.

node/server.js node/tcp/server.js

File renamed without changes.

0 commit comments

Comments
 (0)