get '/about' do send_file 'about.html' end
Gemfile
source 'https://rubygems.org' gem 'sinatra'
gem install sinatra
gem install sinatra-contrib
[vagrant@localhost webapp]$ gem install sinatra Successfully installed sinatra-1.4.7 Parsing documentation for sinatra-1.4.7 Done installing documentation for sinatra after 0 seconds 1 gem installed
let’s try this
[vagrant@localhost ruby2]$ ruby app.ruby -o 192.168.33.10 ruby: No such file or directory -- app.ruby (LoadError) [vagrant@localhost ruby2]$ ruby app.rb -o 192.168.33.10 == Sinatra (v1.4.7) has taken the stage on 4567 for development with backup from Puma Puma starting in single mode... * Version 3.6.0 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity * Min threads: 0, max threads: 16 * Environment: development * Listening on tcp://192.168.33.10:4567 Use Ctrl-C to stop 192.168.33.1 - - [14/Jan/2017:08:54:48 +0900] "GET / HTTP/1.1" 404 466 0.0379 192.168.33.1 - - [14/Jan/2017:08:54:48 +0900] "GET /__sinatra__/404.png HTTP/1.1" 200 18893 0.0065 192.168.33.1 - - [14/Jan/2017:08:54:48 +0900] "GET /favicon.ico HTTP/1.1" 404 477 0.0007 ^C== Sinatra has ended his set (crowd applauds) - Gracefully stopping, waiting for requests to finish === puma shutdown: 2017-01-14 08:55:18 +0900 === - Goodbye!
verb path do #do something! end
here is a example
post '/login' do #do something! end