Open mulderp opened 11 years ago
Additionally, some interesting variation might be include Redis or some store to load data from a DB, instead of files.
Isn't easier to place your file inside public
and let the Static server serve it? (I guess it should work)
Thanks, indeed, placing the JSON in the public works too. The approach with Sinatra then only would make sense, when a resources/files would be created, or a database would be involved.
Well, some of the original idea was to have some way to get started with API development in Ruby too. A similar approach to: http://www.arangodb.org/foxx and more ideas on API co-development here: http://www.arangodb.org/2013/05/14/ideas-and-facts-from-scotland-js-in-edinburgh
The idea of this PR is a way to get JSON into the browser. This might be interesting when designing views for data that is loaded with Ajax, e.g some movies collection.
By putting a file ./data/movies.json with content:
it is possible to load the JSON from the browser with e.g.:
results into
Underlying this is Sinatra reading all .json files from the ./data directory.
What do you think?