How to use the connect.staticProvider function in connect

To help you get started, we’ve selected a few connect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kn0ll / backbone-osc / server.js View on Github external
var osc_send = new osc.Client(8000, '127.0.0.1');
        
        // listen from client on port 8000
        // to create osc signal
        client.on('message', function(data) {
            
            var args = data.split('/'),
                val = args.pop();
            osc_send.sendSimple(args.join('/'), [parseFloat(val)]);
           
        });
        
    }),
    
    Connect.staticProvider(__dirname + '/static'),
    
    Connect.router(function(app){
        
        app.get('/', function(req, res, next){
            res.writeHead(200, { 'Content-Type': 'text/html' })
            Fs.readFile('./views/index.html', 'utf8', function (err, html) {
                res.end(_.template(html, req.params))
            })
        })
        
    })
    
).listen(8080)
github past / nodify / server.js View on Github external
var connect = require('connect'),
	api = require('./api'),
	port = parseInt(process.env.PORT) || 8000;

var server = connect.createServer(
	connect.logger(),
	connect.errorHandler({ dumpExceptions: true, showStack: true })
);
// Serve static resources.
server.use("/",
    connect.conditionalGet(),
    connect.cache(),
    connect.gzip(),
	connect.staticProvider(__dirname + '/public')
);
// Serve the API responses.
server.use("/api",
	connect.bodyDecoder(),
	connect.cookieDecoder(),
	connect.router(api.router)
);
server.listen(port);
console.log('Nodify server running at http://127.0.0.1:' + port);

process.addListener('uncaughtException', function (err) {
	console.log(err.stack);
});
github joyent / node-camp / exploder / server.js View on Github external
var Connect = require('connect');

var PORT = process.env.PORT || 8081;

// Serve static files and log requests to the server
Connect.createServer(
  Connect.logger(),
  Connect.staticProvider('web')
).listen(PORT);

console.log("Exploder server running at http://localhost:%s", PORT);
github kof / node-ams / lib / server.js View on Github external
server, listen,
        connectTypes = connect.utils.mime.types,
        ext;

    // add all mime types from connect list
    if (!o.compress) {
        o.compress = [];
        for (ext in connectTypes) {
            o.compress.push(connectTypes[ext]);
        }
    }

    server = connect.createServer(
        connect.conditionalGet(),
        connect.cache(),
        connect.staticProvider(o),
        connect.gzip(),
        connect.staticGzip(o)
    );

    listen = server.listen;

    server.listen = function(port) {
        util.log('ams server is running on port ' + port);
        return listen.apply(this, arguments);
    };

    return server;
};
github creationix / howtonode.org / articles / connect-it / app2.js View on Github external
var Connect = require('connect');

module.exports = Connect.createServer(
  Connect.logger(), // Log responses to the terminal using Common Log Format.
  Connect.responseTime(), // Add a special header with timing information.
  Connect.conditionalGet(), // Add HTTP 304 responses to save even more bandwidth.
  Connect.cache(), // Add a short-term ram-cache to improve performance.
  Connect.gzip(), // Gzip the output stream when the browser wants it.
  Connect.staticProvider(__dirname) // Serve all static files in the current dir.
);
github dotmaster / Touchable-jQuery-Plugin / utils / server.js View on Github external
var connect = require('connect')
      , express = require('express')
      , sys = require('sys');
      require('assert');
  
      //Create Express frontend
var server = global.server = express.createServer();
server.use(connect.staticProvider(__dirname+'/..'));
server.use(express.errorHandler({ dumpExceptions: true, showStack: true }));                  


var port=3000;
server.listen(port);
console.log('Server Listening on http://0.0.0.0:'+port);
github joemccann / Lingua / server / app.js View on Github external
app.configure(function () 
{
    app.set('views', __dirname + '/views');
    app.use('/', connect.bodyDecoder());
    app.use('/', connect.methodOverride());
    app.use(connect.staticProvider(__dirname + '/public'));
});
github TooTallNate / nTunes / app.js View on Github external
var connect = require("connect");

module.exports = require("./lib/nTunes").createServer(
  connect.logger(),
  connect.staticProvider(__dirname + "/www")
);
github aelaguiz / canvas-typeface.js / example / runme.js View on Github external
server.configure(function(){
    server.set('views', __dirname + '/views');
    server.use(connect.bodyDecoder());
    server.use(connect.staticProvider(__dirname + '/static'));
    server.use(server.router);
});