Skip to content

Instantly share code, notes, and snippets.

@vanderhoop
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save vanderhoop/86b686bfca3b14ee9d14 to your computer and use it in GitHub Desktop.

Select an option

Save vanderhoop/86b686bfca3b14ee9d14 to your computer and use it in GitHub Desktop.

Sinatra Calculator

Objective:

  • Build a simple Sinatra app with GET and POST

Prompt

  • You will be building a calculator once again, but this time it will work with the internet.
  • You should make git commits as you finish each phase, so you can see the history.

####Specification:

  • When they visit the homepage (GET) (/), a user should see some text to welcome them to the calculator
  • When they visit the /calculations page (GET), a user should be able to see all of the calculations that have been done in the past
  • A user can see a the third calculation they've done in the past by visiting /calculations/3 (GET). Same with any other number. If the calculation doesn't exist, they should see text saying that the id wasn't found.
  • A user can POST an Addition calculation to /calculations/add by providing 2 numbers as parameters.
    • Use the POSTman Chrome extension to try out your POST
  • Same with /calculations/subtract, /calculations/multiply, and /calculations/divide
  • The calculator can add, subtract, multiply and divide.

Bonus

  • Translate one line of your MTA app to Sinatra
    • Example: When I visit /mta/times_square/union_square using a GET, I should see "Your trip length from Times Square to Union Square is 4 stops." in the browser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment