1. Creating a basic Sinatra Project
Building your first basic Sinatra project
Guides, tutorials and labs to accompany CMU's Programming for Online Prototypes (49-714).
Everything you need to know about building microservices for the web with Ruby and Sinatra.
Let’s say we want to add a little more interaction to our server. To do this we’ll want to be able to respond to more than just requests for the root URL. And sinatra let’s you do that. In your program you can add as many routes as you like.
Try it by adding the following to your app.rb and save your file
get '/about' do
'A little about me.'
end
This should add a new endpoint to our server that maps to http://localhost:4567/about
. If the ‘/about’ URL is requested (using the GET HTTP method), “A little about me.” will display.
This series guides you through creating your first Sinatra project and some of the features it offers for creating web-delivered apps
Building your first basic Sinatra project
Building your first basic Sinatra project
Routing with HTTP Methods explained
How to include named parameters in defined routes
Storing User Information in Sessions
How to return a HTTP error response
Using configuration blocks to store application wide variables