-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
30 lines (24 loc) · 831 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
var cc = require('config-multipaas'),
restify = require('restify'),
fs = require('fs')
var config = cc(),
app = restify.createServer()
app.use(restify.queryParser())
app.use(restify.CORS())
app.use(restify.fullResponse())
// Routes
app.get('/status', function (req, res, next)
{
res.send("{status: 'ok'}");
});
app.get('/', function (req, res, next)
{
var data = fs.readFileSync(__dirname + '/index.html');
res.status(200);
res.header('Content-Type', 'text/html');
res.end(data.toString().replace(/host:port/g, req.header('Host')));
});
app.get(/\/(css|js|img)\/?.*/, restify.serveStatic({directory: './static/'}));
app.listen(config.get('PORT'), config.get('IP'), function () {
console.log( "Listening on " + config.get('IP') + ", port " + config.get('PORT') )
});