Skip to content

Instantly share code, notes, and snippets.

@zapidan
Created November 6, 2015 17:00
Show Gist options
  • Save zapidan/4aeda61b63cd36dfae88 to your computer and use it in GitHub Desktop.
Save zapidan/4aeda61b63cd36dfae88 to your computer and use it in GitHub Desktop.
Simple Express Server that serves files on /public folder
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