Created
August 5, 2011 02:56
-
-
Save eugeniy/1126837 to your computer and use it in GitHub Desktop.
A sample node script with some Connect middleware and a couple routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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