app.js.https 1.0 KB

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