Last active
January 18, 2016 19:45
-
-
Save mauricioschneider/129fefd9bfc219e1ae3e to your computer and use it in GitHub Desktop.
root_opts
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 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