Skip to content

Instantly share code, notes, and snippets.

@davesag
Created April 11, 2014 07:14
Show Gist options
  • Save davesag/10446082 to your computer and use it in GitHub Desktop.
Save davesag/10446082 to your computer and use it in GitHub Desktop.
A very simple hello-world http server in Coffeescript
###
A hello world server written in Coffeescript
Step 0: Install Node.js `brew install node`
Step 1: Install Coffeescript `npm install -g coffee-script`
Step 2: `coffee -c hello-world-server.coffee`
Step 3: `node hello-world-server`
Step 4: point your browser of choice at http://localhost:8000
Profit!
`control-c` to quit.
Thrown together hastily by Dave Sag <[email protected]>
###
http = require "http"
http.createServer( (req, res) ->
body = "Hello World!"
headers =
'Content-Type': "text/plain"
'Content-Length': body.length
res.writeHead 200, headers
res.end body, 'utf8'
).listen 8000
console.log "Server running at http://127.0.0.1:8000/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment