background preloader

Sinatra

Facebook Twitter

Rack (web server interface) Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby.

Rack (web server interface)

By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call. app = lambda do |env| body = "Hello, World! " [200, {"Content-Type" => "text/plain", "Content-Length" => body.length.to_s}, [body]]end run app There is a Rack IRC channel #rack at Freenode.

Sinatra/sinatra. Sinatra. Sinatra (software) Designed and developed by Blake Mizerany, Sinatra is small and flexible. It does not follow the typical model–view–controller pattern used in other frameworks, such as Ruby on Rails. Instead, Sinatra focuses on "quickly creating web-applications in Ruby with minimal effort. "[1] Sinatra was created and open-sourced in 2007. Sinatra has inspired a lot of micro frameworks in Ruby and other programming languages. In July 2011, some unknown individual or group, posing as various members of the Sinatra core team, discredited the Dancer project. Sinatra: README. This page is also available in Chinese, French, German, Hungarian, Korean, Portuguese (Brazilian), Portuguese (European), Russian, Spanish and Japanese.

Sinatra: README

Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort: # myapp.rb require 'sinatra' get '/' do 'Hello world! 'end Install the gem: And run with: View at: It is recommended to also run gem install thin, which Sinatra will pick up if available. Routes. Sinatra Book. A Beginner's Sinatra Tutorial - Joe Yates' Blog. In the olden days your first program was probably in BASIC and was run from the command line, nowadays the equivalent is Web programming.

A Beginner's Sinatra Tutorial - Joe Yates' Blog

Using Sinatra reminds me of my first programming experiences – you write a tiny bit of code, with no boilerplate and get to see a result. What follows owes a lot to the Sinatra README. On Linux, you’ll need Ruby and Rubygems installed (if not you should find installation instructions easily enough via a Web search). Apart from Ruby, you’ll need to use a text editor (e.g.

GEdit) a Web browser and the Terminal (normally found in the Applications menu under Accessories). Get started with Sinatra. This article first appeared in issue 239 of .net magazine – the world's best-selling magazine for web designers and developers.

Get started with Sinatra

Most famous for Ruby on Rails, Ruby is fun, easy to use, easy to understand and easy to learn. Sinatra is a very different framework, which is written in under 2,000 lines of Ruby and doesn’t enforce model-view-controller (MVC) or ship with different tools, configuration files or scaffolding. Sinatra applications are often a single file that contain just enough to get the job done. Just Do It: Learn Sinatra, Part One. In this 4-part series of tutorials, I’m going to take you through the process of creating a fully functioning To Do List app called ‘Just Do It’, using Sinatra and DataMapper.

Just Do It: Learn Sinatra, Part One

Hopefully, this will help to demonstrate just how quick and easy it easy to use Sinatra. Let’s begin with the basics of Sinatra. Installing Sinatra To get started with Sinatra, you’ll need to have Ruby installed. I would recommend using RVM for this (you can follow this great guide by Glenn Goodrich if you need help).

A Basic Application To start with, open up your favorite text editor and save the following as main.rb. Note – If you are using a version of Ruby less than 1.9, you will need to put the line require 'rubygems' at the top of this file. This is about as basic as a Sinatra application can get: You have to require the sinatra gem at the top, then the real action starts on line 3. Singing with Sinatra. Welcome to Track 1 of "Singing with Sinatra.

Singing with Sinatra

" In this mini-series we'll be taking a look at Sinatra; a small, yet incredibly powerful DSL for quickly creating Ruby web applications. In this part, we'll get started with Sinatra by playing around with a few routes, learning how to access URL parameters and how to POST data between pages. If you haven't worked with Ruby before, you should check out the Ruby for Newbies session, where Andrew will guide you through the process of installing Ruby on your system and learning the basics of the language.

First thing we need to do is install the Sinatra RubyGem. Enter the following into the Terminal: Also install the 'shotgun' gem, which we'll use later: Depending on how you have RubyGems set up on your system, you may need to prefix the gem install commands with sudo. The Very Basics Open your text editor and create a new file named basics.rb. Let's start off by creating the classic "Hello World".