Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kevinchisholm/9eebc91a6e327d6a740f7da18b918f33 to your computer and use it in GitHub Desktop.
Save kevinchisholm/9eebc91a6e327d6a740f7da18b918f33 to your computer and use it in GitHub Desktop.
Set Up A Node / Express Static Web Server In Five Minutes
var express = require('express'),
path = require('path'),
app = express();
//set the port
app.set('port', 3000);
//tell express that we want to use the www folder
//for our static assets
app.use(express.static(path.join(__dirname, '../www')));
// Listen for requests
var server = app.listen(app.get('port'), function () {
console.log('The server is running on http://localhost:' + app.get('port'));
});
{
"name": "node-express-static-web-server",
"version": "1.0.0",
"description": "Node Express Static Web Server",
"scripts": {
"start": "node web-server/app.js"
},
"author": "Kevin Chisholm",
"license": "MIT",
"dependencies": {
"express": "4.13.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment