123456789101112131415161718192021222324
  1. var express = require('express');
  2. var app = express();
  3. var morgan = require('morgan');
  4. var bodyParser = require('body-parser');
  5. var cors = require('cors');
  6. app.use(morgan('dev'));
  7. app.use(bodyParser.urlencoded({'extended':'true'}));
  8. app.use(bodyParser.json());
  9. app.use(cors());
  10. app.use(function(req, res, next) {
  11. res.header("Access-Control-Allow-Origin", "*");
  12. res.header('Access-Control-Allow-Methods', 'DELETE, PUT');
  13. res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  14. next();
  15. });
  16. app.use(express.static('www'));
  17. app.set('port', process.env.PORT || PORT);
  18. app.listen(app.get('port'), function () {
  19. console.log('Express server listening on port ' + app.get('port'));
  20. });