Skip to content

Instantly share code, notes, and snippets.

@tinacious
Created July 17, 2014 13:15
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 tinacious/0d4b6c3ae36e2f96b05f to your computer and use it in GitHub Desktop.
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 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