<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lasse Bunk&#039;s weblog &#187; Sinatra</title>
	<atom:link href="http://lassebunk.dk/tag/sinatra/feed/" rel="self" type="application/rss+xml" />
	<link>http://lassebunk.dk</link>
	<description>Ruby on Rails, programming, and SEO</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:51:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Sinatra to serve smaller (than Rails) applications</title>
		<link>http://lassebunk.dk/2010/02/25/using-sinatra-to-serve-smaller-than-rails-applications/</link>
		<comments>http://lassebunk.dk/2010/02/25/using-sinatra-to-serve-smaller-than-rails-applications/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 14:19:55 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Rack]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Sinatra]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=1147</guid>
		<description><![CDATA[How to use Sinatra instead of Ruby on Rails to server small applications.]]></description>
			<content:encoded><![CDATA[<p>So, maybe you&#8217;ve been coding <a href="http://rubyonrails.org">Rails</a> for a while and wondered &#8211; &#8220;do I really need this full stack framework to serve even small applications?&#8221;. Well, no you don&#8217;t <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Check out <a href="http://dns.norbauer.com">Norbauer&#8217;s DNS Tools</a> (and on <a href="http://github.com/norbauer/dns-tools">Github</a>). It&#8217;s a small set of easy to use DNS tools. So small it would be overkill to serve it using Rails.</p>
<p>Norbauer&#8217;s using <a href="http://www.sinatrarb.com/">Sinatra</a> to serve the app.</p>
<p>Start by installing the gem:</p>
<pre class="brush: bash; title: ; notranslate">
$ sudo gem install sinatra
</pre>
<p>After that it&#8217;s as simple as this:</p>
<pre class="brush: ruby; title: ; notranslate">
# myapp.rb
require 'rubygems'
require 'sinatra'

get '/' do
  &quot;Welcome to my homepage!&quot;
end

get '/contact' do
  &quot;My contact info is...&quot;
end
</pre>
<p>At your terminal:</p>
<pre class="brush: bash; title: ; notranslate">
$ ruby myapp.rb
== Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Mongrel
</pre>
<p>Now you can view it in your browser at <a href="http://localhost:4567">http://localhost:4567</a> and <a href="http://localhost:4567/contact">http://localhost:4567/contact</a>. Simple.</p>
<p>This is great for hosting apps from your command line (for example check out <a href="http://adam.blog.heroku.com/past/2009/2/11/taps_for_easy_database_transfers/">Taps</a>) but what if you wanted to serve it like you would a Rails app?</p>
<p>Well, then you&#8217;d be using <a href="http://rack.rubyforge.org/">Rack</a>.</p>
<p>Create a file named <code>config.ru</code> in the same folder as <code>myapp.rb</code>:</p>
<pre class="brush: ruby; title: ; notranslate">
require 'myapp'
run Sinatra::Application
</pre>
<p>Now you can deploy your application as you would if it was written in Rails (thanks to <code>config.ru</code>).<br />
If you want to check this setup at your localhost, run the following:</p>
<pre class="brush: bash; title: ; notranslate">
$ sudo gem install rack # make sure you have Rack installed
$ rackup # run the Rack application using config.ru
</pre>
<p>It&#8217;s as easy as that! Great for hosting small applications.</p>
<p>Also see:</p>
<ul>
<li><a href="http://rack.rubyforge.org/doc/">List of Rack compliant web servers</a></li>
<li><a href="http://www.modrails.com/documentation/Users%20guide.html#_deploying_a_rack_based_ruby_application">Deploying a Rack-based Ruby application [with Phusion Passenger]</a></li>
</ul>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2010/02/25/using-sinatra-to-serve-smaller-than-rails-applications/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

