Created
July 17, 2014 13:15
-
-
Save tinacious/0d4b6c3ae36e2f96b05f to your computer and use it in GitHub Desktop.
Using Express to serve a static site on Node.js for easy deploy to Heroku
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
/** | |
* This is your Node app's main file | |
* Don't forget to run `heroku ps:scale web=1` in the Terminal | |
*/ | |
var express = require('express'); | |
var http = require('http'); | |
var path = require('path'); | |
var app = express(); | |
app.set('port', process.env.PORT || 3000); | |
app.use(express.static(path.join(__dirname, 'public'))); | |
if ('development' == app.get('env')) { | |
app.use(express.errorHandler()); | |
} | |
http.createServer(app).listen(app.get('port'), function(){ | |
console.log('Express server listening on port ' + app.get('port')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment