-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtestServer.js
More file actions
32 lines (26 loc) · 747 Bytes
/
testServer.js
File metadata and controls
32 lines (26 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var http = require('http');
var fs = require('fs')
var url = require('url')
require('./build') // build the bundles
var server = http.createServer(function (request, res) {
try {
var requestUrl = url.parse(request.url)
var path = requestUrl.pathname
if(path !== '/favicon.ico') {
console.log("got request for: "+path)
if(path === '/') {
path = '/test/testStackinfo.html'
}
res.writeHead(200)
res.write(fs.readFileSync(__dirname+path))
}
} catch(e) {
console.log(e.message)
res.writeHead(400)
} finally {
res.end()
}
})
var port = 8100
server.listen(port)
console.log("listening on port "+port)