Created
January 22, 2012 12:49
-
-
Save ecylmz/1656976 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
http = require 'http' | |
store = # we'll use a simple object as our store | |
foo: 'bar' | |
coffee: 'script' | |
server = http.createServer (req, res) -> | |
console.log req.method, req.url | |
value = store[req.url[1..]] | |
if not value | |
res.writeHead 404 | |
else | |
res.writeHead 200, | |
'Content-Type': 'text/plain' | |
'Content-Length': value.length + 1 | |
res.write value + '\n' | |
res.end() | |
server.listen 8000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment