Created
October 21, 2010 16:02
-
-
Save grayrest/638758 to your computer and use it in GitHub Desktop.
basic http hello world
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http = require 'http' | |
flow = require('../lib/conductor').conductor() | |
#nodes | |
port= flow.node 'port', () -> 8000 | |
listener= flow.node 'listener', (port, request, response) -> | |
server= http.createServer (req, res) -> | |
request(req) if request | |
response(res) if response | |
server.listen port | |
handler= flow.node 'handler', (request) -> 'hello world!\n' | |
responder= flow.node 'responder', (body, response) -> | |
response.writeHead 200, {'Content-Type': 'text/plain'} | |
response.end body | |
#connect | |
port.output = listener.args.port | |
listener.args.request = handler.args.request | |
handler.output = responder.args.body | |
listener.args.response = responder.args.response | |
#execute | |
flow.execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment