-
Notifications
You must be signed in to change notification settings - Fork 58
/
server.js
36 lines (30 loc) · 1008 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
35
36
var cc = require('config-multipaas'),
finalhandler= require('finalhandler'),
http = require("http"),
Router = require('router'),
fs = require('fs'),
serveStatic = require("serve-static");
var config = cc();
var app = Router()
// Serve up public/ftp folder
app.use(serveStatic('static'))
// Routes
app.get("/status", function (req, res) {
res.statusCode = 200
res.setHeader('Content-Type', 'application/json; charset=utf-8')
res.end("{status: 'ok'}\n")
})
app.get("/", function (req, res) {
var index = fs.readFileSync(__dirname + '/index.html')
res.statusCode = 200
res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.end(index.toString())
})
// Create server
var server = http.createServer(function(req, res){
var done = finalhandler(req, res)
app(req, res, done)
})
server.listen(config.get('PORT'), config.get('IP'), function () {
console.log( "Listening on " + config.get('IP') + ", port " + config.get('PORT') )
});