Skip to content

Instantly share code, notes, and snippets.

@frankcash
Created April 6, 2015 14: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 frankcash/62c295e8466b2767c8ec to your computer and use it in GitHub Desktop.
Save frankcash/62c295e8466b2767c8ec to your computer and use it in GitHub Desktop.
Starter server
var express = require('express');
var cons = require('consolidate');
var bodyParser = require('body-parser');
var fs = require('fs');
var path = require('path');
var app = express();
app.set('view engine', 'html');
app.engine('html', cons.swig); // sets template engine
app.set('views', __dirname + '/views'); // sets dir for views
app.use(express.static(__dirname + '/public'));
// sets up CORS
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.get('/', function(req,res){
res.render('index',{ });
});
app.listen(3000);
console.log('Server started: http://localhost:3000/');
{
"name": "Sample",
"version": "0.0.1",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.4.3",
"consolidate": "^0.12.1",
"express": "^4.4.5",
"swig": "^1.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment