Skip to content

Instantly share code, notes, and snippets.

@afternoon
Created December 3, 2012 22:47
Show Gist options
  • Save afternoon/4198841 to your computer and use it in GitHub Desktop.
Save afternoon/4198841 to your computer and use it in GitHub Desktop.
nodemachine resource in coffeescript
sys = require("sys")
http = require("http")
nodemachine = require("nodemachine")
class EchoMachine extends nodemachine.App
canHandleResource: (context) -> true
getResource: (context, callback) ->
context.res.sendBody(context.req.url)
callback(context, true)
port = process.argv[2] or 80
server = nodemachine.createServer(port)
server.addApp(new EchoMachine())
server.start()
console.log("Started nodemachine on port #{port}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment