Created
October 1, 2015 19:55
-
-
Save RomainKurtz/644d38674443b444b1cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require('express')(); | |
var __dirname = "./public/" | |
/* serves main page */ | |
app.get("/", function(req, res) { | |
res.sendfile( __dirname +'index.html'); | |
}); | |
app.post("/user/add", function(req, res) { | |
/* some server side logic */ | |
res.send("OK"); | |
}); | |
/* serves all the static files */ | |
app.get(/^(.+)$/, function(req, res){ | |
console.log('static file request : ' + req.params); | |
res.sendfile( __dirname + req.params[0]); | |
}); | |
var port = process.env.PORT || 5000; | |
var server = app.listen(port, function() { | |
console.log("Listening on " + port); | |
}); | |
var io = require('socket.io').listen(server); | |
io.on('connection', function(){ | |
console.log('New Socket Client !'); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment