Created
April 6, 2015 14:19
-
-
Save frankcash/62c295e8466b2767c8ec to your computer and use it in GitHub Desktop.
Starter server
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 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/'); |
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
{ | |
"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