July 2008 Archives

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

About this Archive

This page is an archive of entries from July 2008 listed from newest to oldest.

June 2008 is the previous archive.

November 2009 is the next archive.

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

Powered by Movable Type 4.0