Resource: http://www.sinatrarb.com/intro.html
#myapp.rb
require 'sinatra'
get '/' do
'Hello World!'
end
Install the sinatra gem by running the following command in the terminal
gem install sinatra
-
Start the sinatra server in terminal by running
ruby myapp.rb -
Navigate to
http://localhost:4567in browser -
When you are finished stop the sever by pressing
control + c
-
Visit
http://getbootstrap.com/and click download button. -
Create and
public/andviews/folders in you sinatra app's root directory -
Unzip the bootstrap download and move the
css,fonts, andjsfolders into you sinatra app's public folder. -
Visit
http://getbootstrap.com/getting-started/#examplesgrab an eample template. -
Create a new file index.erb and paste contents of example tbs tempate changing css and js to use correct relative paths.
-
Map the '/' route to your new template
# myapp.rb
require 'sinatra'
get '/' do
erb :index
end
-
Start the server back up byrunning
ruby myapp.rb -
Navigate your browser to http://localhost:4567/