-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (25 loc) · 950 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
27
28
29
30
31
32
33
34
'use strict';
var fs =require('fs'); //for image upload file handling
var express = require('express');
var app = express();
var port =3000;
var host ='localhost';
var serverPath ='/';
var staticPath ='/';
var staticFilePath = __dirname + serverPath;
// remove trailing slash if present
if(staticFilePath.substr(-1) === '/'){
staticFilePath = staticFilePath.substr(0, staticFilePath.length - 1);
}
app.configure(function(){
// compress static content
app.use(express.compress());
app.use(serverPath, express.static(staticFilePath)); //serve static files
app.use(express.bodyParser()); //for post content / files - not sure if this is actually necessary?
});
//catch all route to serve index.html (main frontend app)
app.get('*', function(req, res){
res.sendfile(staticFilePath + staticPath+ 'index.html');
});
app.listen(port);
console.log('Server running at http://'+host+':'+port.toString()+'/');