app.js 818 B

123456789101112131415161718192021222324252627
  1. var express = require('express');
  2. var app = express.createServer();
  3. app.configure(function(){
  4. app.use(express.methodOverride());
  5. app.use(express.bodyParser());
  6. app.use(app.router);
  7. app.set('view engine', 'jade');
  8. app.set('views', __dirname + '/public');
  9. app.set('view options', {layout: false});
  10. app.set('basepath',__dirname + '/public');
  11. });
  12. app.configure('development', function(){
  13. app.use(express.static(__dirname + '/public'));
  14. app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
  15. });
  16. app.configure('production', function(){
  17. var oneYear = 31557600000;
  18. app.use(express.static(__dirname + '/public', { maxAge: oneYear }));
  19. app.use(express.errorHandler());
  20. });
  21. console.log("Web server has started.\nPlease log on http://127.0.0.1:3001/index.html");
  22. app.listen(3001);