Skip to content

Commit a8d88cd

Browse files
substacksubstack
substack
authored and
substack
committed
using ecstatic
1 parent c90ac0e commit a8d88cd

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>404!!!!</h1>
2+
<div>file not found</div>
491 KB
Loading

node/modular-http-server/server.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var http = require('http')
2+
var fs = require('fs')
3+
var ecstatic = require('ecstatic')
4+
var st = ecstatic(__dirname + '/public')
5+
var count = 0
6+
7+
var server = http.createServer(function (req, res) {
8+
console.log(req.method, req.url)
9+
if (req.method === 'GET' && req.url === '/') {
10+
res.setHeader('content-type', 'text/html')
11+
res.end(`<h1>HOWDY</h1>
12+
<div>you are the ${count++}th visitor</div>
13+
<div>sign my guestbook</div>
14+
`)
15+
} else st(req, res)
16+
})
17+
server.listen(3000)

0 commit comments

Comments
 (0)