Skip to content

Instantly share code, notes, and snippets.

@eugeniy
Created August 5, 2011 02:56
Show Gist options
  • Save eugeniy/1126837 to your computer and use it in GitHub Desktop.
Save eugeniy/1126837 to your computer and use it in GitHub Desktop.
A sample node script with some Connect middleware and a couple routes
var connect = require('connect');
var server = connect.createServer();
// Middleware
server.use(connect.logger());
server.use(connect.static(__dirname + '/public'));
// Routes
server.use(connect.router(function(app) {
app.get('/', function(req, res) {
res.end('Hello, World!');
});
app.get('/:name', function(req, res) {
res.end('Hello from connect, ' + req.params.name);
});
}));
server.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment