Skip to content

Instantly share code, notes, and snippets.

@ecylmz
Created January 22, 2012 12:49
Show Gist options
  • Save ecylmz/1656976 to your computer and use it in GitHub Desktop.
Save ecylmz/1656976 to your computer and use it in GitHub Desktop.
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