Sinatra is a web application framework for rapidly building applications in Ruby. Sinatra is a domain specific language or DSL which means it is designed from the ground up to build applications with minimal efforts. It is written in Ruby.
//Enabling Session enable :sessions get '/foo' do // setting session value session[:message] = 'Hello World!' redirect to('/bar') end get '/bar' do // getting session value session[:message] # => 'Hello World!' end
require 'sinatra/base' require 'rack-flash' class MyApp < Sinatra::Base enable :sessions use Rack::Flash post '/set-flash' do # Set a flash entry flash[: notice] = "Thanks for signing up!" # Get a flash entry flash[:notice] # => "Thanks for signing up!" # Set a flash entry for only the current request flash.now[: notice] = "Thanks for signing up!" end end
Never Miss an Articles from us.