Skip to content

Instantly share code, notes, and snippets.

@mauricioschneider
Last active January 18, 2016 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauricioschneider/129fefd9bfc219e1ae3e to your computer and use it in GitHub Desktop.
Save mauricioschneider/129fefd9bfc219e1ae3e to your computer and use it in GitHub Desktop.
root_opts
var express = require('express'),
path = require('path');
var app = express();
// access to views & assets
app.use(express.static('app/views/'));
app.use(express.static('app/assets/css'));
app.use(express.static('app/assets/javascript'));
app.use(express.static('app/assets/javascript/components/'));
app.use(express.static('public'));
app.use(express.static('node_modules/bootstrap/dist/'));
app.get('/index', function(req, res){
sendHtml(res, 'index');
})
app.get('/join', function(req, res){
sendHtml(res, 'join');
})
app.get('/message', function(req, res){
sendHtml(res, 'message');
})
var sendFileOpts = {
root: path.join(__dirname, 'app', 'views')
}
function sendHtml(res, file) {
res.sendFile(file + '.html', sendFileOpts);
}
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment