Skip to content

Instantly share code, notes, and snippets.

@kevinzen
Forked from hugs/LICENSE
Created November 1, 2011 20:22
Show Gist options
  • Save kevinzen/1331788 to your computer and use it in GitHub Desktop.
Save kevinzen/1331788 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"
http.createServer( (req, res) ->
res.sendHeader 200, {"Content-Type": "text/plain"}
res.sendBody "Hello, World!"
res.finish()
).listen 8000
puts "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