-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
26 lines (23 loc) · 876 Bytes
/
server.js
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
// This is a simple static server for dev
// Just start it to you can test your libs
// in a browser using HTTP protocol on port 3000
var static = require('node-static');
var fileServer = new static.Server('./', {
mime: {
'text/html': ['html'],
'text/javascript': ['js'],
}
});
require('http').createServer(function (request, response) {
request.addListener('end', function () {
fileServer.serve(request, response, function (e){
if (e && (e.status === 404)) { // If the file wasn't found
fileServer.serveFile('/index.html', 200, {}, request, response);
}
});
}).resume();
}).listen(3000, function (){
console.log('Open development server at port 3000');
console.log('Files not found will load /index.html for pushState works!');
console.log('http://localhost:3000');
});