Created
June 30, 2011 20:27
-
-
Save bmc/1057146 to your computer and use it in GitHub Desktop.
Sample, simple Sinatra + JSON thingie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
require 'json' | |
get '/', :provides => 'json' do | |
data = {"key1" => ["a", "b"], | |
"key2" => 10} | |
JSON::dump(data) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -v http://localhost:4567 | |
* About to connect() to localhost port 4567 (#0) | |
* Trying ::1... Connection refused | |
* Trying 127.0.0.1... connected | |
* Connected to localhost (127.0.0.1) port 4567 (#0) | |
> GET / HTTP/1.1 | |
> User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18 | |
> Host: localhost:4567 | |
> Accept: */* | |
> | |
< HTTP/1.1 200 OK | |
< Connection: close | |
< Date: Thu, 30 Jun 2011 20:26:42 GMT | |
< Content-Type: application/json | |
< Content-Length: 28 | |
< | |
* Closing connection #0 | |
{"key1":["a","b"],"key2":10} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment