-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (25 loc) · 782 Bytes
/
server.js
File metadata and controls
31 lines (25 loc) · 782 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
var fs = require('fs')
, express = require('express')
, app = express();
app.configure(function(){
// dont cache while testing
app.use(function(req, res, next){
res.header("Cache-Control", "private, no-cache, no-store, must-revalidate");
res.header("Pragma", "no-cache");
next();
});
// set static directory
app.use(express.static(__dirname + '/src'));
// file not found, route to index.html
app.use(function(req, res){
if (req.url.slice(-1) == "/") {
res.redirect(req.url.slice(0,-1));
} else {
res.sendfile('src/index.html', {root: __dirname });
}
});
});
app.listen(8080, '0.0.0.0', function() {
console.log("Listening on port: 8080");
});
module.exports = app;