Skip to content

Instantly share code, notes, and snippets.

@chrisjlee
Created December 19, 2013 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chrisjlee/8044900 to your computer and use it in GitHub Desktop.
Save chrisjlee/8044900 to your computer and use it in GitHub Desktop.
Creating the simple static file server using node.js and express
var express = require('express'),
htmlDir = './html/'
var app = express();
//Log all requests
app.use(express.logger());
//Set content directories
app.use(express.static(__dirname + '/html'));
app.use('/js',express.static(__dirname + '/js'));
app.use('/css', express.static(__dirname + '/css'));
app.use("/image", express.static(__dirname + '/image'));
app.get('/', function(request, response) {
response.sendfile(htmlDir + 'turbocalendulator.html');
});
var port = process.env.PORT || 5000;
app.listen(port, function() {
console.log("Listening on " + port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment