O'Reilly logo

PhoneGap by Andrew Lunny

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – A news site, with an API

  1. Let's get something started as quickly as possible with Sinatra—create a new file called server.rb, and enter the following:
    require 'rubygems'
    require 'sinatra'
        
    get '/' do
        "Hello World"
    end

    The first two lines ensure we have access to Ruby's package manager, RubyGems, and the Sinatra library. The rest of file says that, when our server receives a GET request for the path /, we should respond with the string Hello World.

  2. Run this file by the command ruby server.rb. You should see the following output:
    == Sinatra/1.2.6 has taken the stage on 4567 for development with backup from Thin
    >> Thin web server (v1.2.7 codename No Hup)
    >> Maximum connections set to 1024
    >> Listening on 0.0.0.0:4567, CTRL+C to stop ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required