Created
February 6, 2011 04:30
-
-
Save nikhilm/813128 to your computer and use it in GitHub Desktop.
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 http = require('http'); | |
http.createServer(function (req, res) { | |
var result = req.url.match(/^\/user\/([a-z]+)$/); | |
if( result ) { | |
res.writeHead(200, {'Content-Type': 'text/html'}); | |
res.end('<html><head><title>Greeting App</title></head><body><h1>Hello '+ result[1] + '!</h1></body></html>'); | |
} | |
else { | |
res.writeHead(403); | |
res.end("You aren't allowed here!"); | |
} | |
}).listen(5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment