Last active
October 11, 2015 03:38
-
-
Save lupomontero/3797388 to your computer and use it in GitHub Desktop.
Example nodejs server using express
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
#!/usr/bin/env node | |
var express = require('express'); | |
var port = process.argv[2] || 8080; | |
var ip = process.argv[3] || '127.0.0.1'; | |
var app = express(); | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'hbs'); | |
app.use(express.static(__dirname + '/public')); | |
app.get('/', function (req, res, next) { | |
res.render('index', { title: 'A test app', node_version: process.version }); | |
}); | |
app.listen(port, ip, function () { | |
console.log('nodejs ' + process.version + ' server listening on ' + ip + ':' + port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment