Last active
April 26, 2018 04:59
-
-
Save kevinchisholm/9eebc91a6e327d6a740f7da18b918f33 to your computer and use it in GitHub Desktop.
Set Up A Node / Express Static Web Server In Five Minutes
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
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')); | |
}); |
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
{ | |
"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