Skip to content

Instantly share code, notes, and snippets.

@lishiyo
Created June 9, 2015 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lishiyo/f79d9b8971cdf4a8f9ca to your computer and use it in GitHub Desktop.
Save lishiyo/f79d9b8971cdf4a8f9ca to your computer and use it in GitHub Desktop.
Sample Express Server
{
"name": "sample-server",
"version": "0.0.0",
"description": "Code from the React tutorial.",
"main": "server.js",
"dependencies": {
"body-parser": "^1.4.3",
"express": "^4.4.5"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"engines" : {
"node" : "0.12.x"
}
}
// var fs = require('fs');
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, '/')));
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') + '/');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment