Skip to content

Instantly share code, notes, and snippets.

@Syd
Created February 19, 2009 10:37
Show Gist options
  • Save Syd/66854 to your computer and use it in GitHub Desktop.
Save Syd/66854 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'eventmachine'
module SimpleResponse
def receive_data data
if data =~ /^GET/
then
send_data "HTTP/1.1 200\nContent-type: text/plain\n\nHello World!"
close_connection_after_writing
else
close_connection
end
end
end
EventMachine::run {
EventMachine::start_server "0.0.0.0", 8081, SimpleResponse
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment