Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RomainKurtz/644d38674443b444b1cb to your computer and use it in GitHub Desktop.
Save RomainKurtz/644d38674443b444b1cb to your computer and use it in GitHub Desktop.
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