daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Oct 21st, 2018 59 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. /**
  2.  * Module dependencies.
  3.  */
  4.  
  5. var express = require('express')
  6.   , routes = require('./routes')
  7.   , fs = require('fs')
  8.   , spdy = require('node-spdy')
  9.  
  10. var options = {
  11.   key: fs.readFileSync(__dirname + "/keys/spdy-key.pem"),
  12.   cert: fs.readFileSync(__dirname + "/keys/spdy-cert.pem"),
  13.   ca: fs.readFileSync(__dirname + "/keys/spdy-csr.pem")
  14. }
  15. var app = module.exports = spdy.createServer(express.HTTPSServer, options);
  16.  
  17. // Configuration
  18.  
  19. app.configure(function(){
  20.   app.set('views', __dirname + '/views');
  21.   app.set('view engine', 'ejs');
  22.   app.use(express.bodyParser());
  23.   app.use(express.methodOverride());
  24.   app.use(app.router);
  25.   app.use(express.static(__dirname + '/public'));
  26. });
  27.  
  28. app.configure('development', function(){
  29.   app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
  30. });
  31.  
  32. app.configure('production', function(){
  33.   app.use(express.errorHandler());
  34. });
  35.  
  36. // Routes
  37.  
  38. app.get('/', function(req, res) {
  39.   var headers = { 'content-type' : 'application/javascript' };
  40.   res.push('/main.js', headers, function(err, stream) {
  41.     console.log(err);
  42.     if(err) return;
  43.  
  44.     stream.end('alert("hello from push stream!");');
  45.   });
  46.  
  47.   res.render('index', { title: 'Express' })
  48. });
  49.  
  50.  
  51. app.get('/check', function(req, res) {
  52.   res.writeHead(200);
  53.   res.write("streamID => " + req.streamID + "\n");
  54.   res.write("isSpdy => " + req.isSpdy);
  55.   res.end("");
  56. });
  57.  
  58. app.listen(3000, function(){
  59.   console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
  60. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top