Created: 2014-05-18 16:21
Updated: 2014-06-21 20:02


A very basic python webserver that returns a reversed message string. The initial code was taken from this but modified to handle JSON.


Start the server with the following:

python 51714

The call it with the following POST request

wget -O- --post-data='{"message": "A red Ball"}' --header=Content-Type:application/json ""


I am working on a ruby on rails product that includes some natural language processing. Python has much better libraries so wanted a way for them both to talk to each other. Below is some Ruby code to call the server.

require 'net/http'
require 'uri'
require 'json'

uri = URI.parse('http://localhost:51714')

header = {'Content-Type' => 'application/json'}
data = { 'message' => 'A blue ball' }

# Create the HTTP objects
http =, uri.port)
request =, header)
request.body = data.to_json

# Send the request
response = http.request(request)
puts response.body
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more