Homework: MOAR SERVERS!@!@!@1212
MOAR SERVERS
- It is time to build the cutest server ever - the
small_animalsserver! Place this in a new folder in04_ruby101/your_name/calledsmall_animals - Create a brand new, small Sinatra app. Check out the Simplest Sinatra app, ever above for guidance.
- Write a simple Sinatra app with a
Gemfile,config.ru, andapp.rb - Inside of your
app.rb, you need to create a few routes...- '/' - This should return a Hash turned into JSON with the following keys:
:nameand:message - Five different routes mapped to the names of small animals - ie
/kittenand/puppy - These five different routes should return a hash turned JSON with the following keys:
:name,:cuteness,:habitat,:picture_url, and:description
- '/' - This should return a Hash turned into JSON with the following keys:
- Test and verify these routes render JSON in the browser.
- BONUS: Add ERB views and then create a new
/views/json_test.erb. Map it to arouterand call each API call using$.getJSONor$.ajaxto render the content usingconsole.logor whatever else you choose. - BONUS: You can use each animal route's
:picture_urlto render images as a double bonus!