Skip to content

Instantly share code, notes, and snippets.

@robflaherty
Forked from hugs/LICENSE
Created June 18, 2011 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robflaherty/1033183 to your computer and use it in GitHub Desktop.
Save robflaherty/1033183 to your computer and use it in GitHub Desktop.
The Node.js "Hello World" web server ported to CoffeeScript
I, Jason Huggins, the author of the work "CoffeeScript Web Server" (2010), irrevocably renounce
all current and future legal rights to the work in any medium whatsoever.
I stand behind the merit of the work, but disclaim all liability for it under law.
I encourage you, the audience, to share, copy, distribute, perform, remix, mash up, interpret,
excerpt, translate, and otherwise enjoy and use the work as you will.
I request that you acknowledge my authorship.
Digital versions of the work may be available at https://gist.github.com/gists/304374. Learn more
at pleasepirate.org.
# Install Node and CoffeeScript:
# Node : http://github.com/ry/node
# CoffeeScript : http://github.com/jashkenas/coffee-script
#
# In a terminal window:
# $ cd coffee-script
# $ ./bin/node_coffee -r web_server.coffee
#
# Tested with Mac OS X 10.5.8, Node 0.1.26, CoffeeScript 0.5.0
#
# Jeremy Ashkenas has included this script in CoffeeScript's examples directory:
# http://github.com/jashkenas/coffee-script/blob/master/examples/web_server.coffee
http = require 'http'
server = http.createServer (req, res) ->
res.writeHeader 200, 'Content-Type': 'text/plain'
res.write 'Hello, World!'
res.end()
server.listen 8888
console.log "Server running at http://localhost:8888/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment