Lets Post something..

| | Comments (0) | TrackBacks (0)

..and create a Ruby / Webrick Webserver that receives post and gets in seconds:

require ‘webrick’ include WEBrick

class CurrentTimeServlet < WEBrick::HTTPServlet::AbstractServlet

def doGET(request, response) response[‘Content-Type’] = ‘text/plain’ response.status = 200 response.body = Time.now.tos + “\n” end

def do_POST(request, response) puts request.body end end

———————————————————————

Create an HTTP server

s = HTTPServer.new( :Port => 8000 )

s.mount(“/logreceiver”, CurrentTimeServlet)

When the server gets a control-C, kill it

trap(“INT”){ s.shutdown }

Start the server

s.start

http://www.linuxjournal.com/article/8356

0 TrackBacks

Listed below are links to blogs that reference this entry: Lets Post something...

TrackBack URL for this entry: http://www.innoq.com/mt4/mt-tb.cgi/2451

Leave a comment

About this Entry

This page contains a single entry by Rubén Parés-Selders published on July 29, 2008 3:39 PM.

Ruby is the language Buddha would have programmed in was the previous entry in this blog.

Was geht ? Legacy frischgemacht is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.0