silvrgit/app.js

37 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

/* var app = require('express').createServer();
2016-03-08 21:52:21 +00:00
app.get('/', function(req, res) {
res.send('Hello from <a href="http://appfog.com">AppFog.com</a>');
});
app.listen(process.env.VCAP_APP_PORT || 3000);*/
var express = require('express'), path = require('path'), http = require('http');
2016-03-08 21:52:21 +00:00
var app = express();
app.configure(function() {
app.set('port', process.env.VCAP_APP_PORT || 3000);
app.use(express.logger('dev'));
2016-03-08 21:52:21 +00:00
/* 'default', 'short', 'tiny', 'dev' */
app.use(express.methodOverride());
2016-03-08 21:52:21 +00:00
app.use(express.bodyParser());
app.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'X-Requested-With');
next();
});
2016-03-08 21:52:21 +00:00
app.use(app.router);
app.use(express.static(path.join(__dirname, 'www')));
app.use(express.errorHandler({ 'dumpExceptions': true, 'showStack': true }));
2016-03-08 21:52:21 +00:00
});
/**
* Routing handlers
*/
/**
* create the server
*/
http.createServer(app).listen(app.get('port'), function() {
console.log(`Express server listening on port ${ app.get('port')}`);
2016-03-08 21:52:21 +00:00
});