Created
November 6, 2015 17:00
-
-
Save zapidan/4aeda61b63cd36dfae88 to your computer and use it in GitHub Desktop.
Simple Express Server that serves files on /public folder
This file contains 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 path = require('path'); | |
var express = require('express'); | |
var bodyParser = require('body-parser'); | |
var app = express(); | |
app.set('port', (process.env.PORT || 3000)); | |
app.use('/', express.static(path.join(__dirname, 'public'))); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({extended: true})); | |
app.listen(app.get('port'), function() { | |
console.log('Server started: http://localhost:' + app.get('port') + '/'); | |
}); | |
// PORT=5000 node server.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment