<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged rack</title>
<link>https://coderlegion.com/tag/rack</link>
<description>Powered by Question2Answer</description>
<item>
<title>Web &quot;Hello World&quot; in Ruby without RoR!</title>
<link>https://coderlegion.com/24060/web-hello-world-in-ruby-without-ror</link>
<description>&lt;p&gt;If you want to understand how things work beyond what's under the hood, the first good step is to try to write something from scratch. So, in this post, I will show you how to write a 'hello world' app for the web in pure Ruby. Above, you'll find the simple 'Hello World' code example.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ruby&quot;&gt;class MyApp
 def say_hello
   &quot;Hello World&quot;
 end
end
MyApp.new.say_hello
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we need to turn this code into a Rack app. &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/rack/rack&quot;&gt;Rack&lt;/a&gt; is an interface for developing web applications in Ruby. The structure of a Rack app looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ruby&quot;&gt;run do |env|
  [200, {}, [&quot;Hello World&quot;]]
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this case, the code works like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ruby&quot;&gt;class MyApp
 def say_hello
   &quot;Hello World&quot;
 end
end

myapp = proc do |env|
  [200, {'Content-Type' =&amp;gt; 'text/plain'}, [MyApp.new.say_hello]]
end
run myapp
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run this using the rackup gem or another supported web server.(&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/rack/rack#usage&quot;&gt;read more here&lt;/a&gt;)&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ruby&quot;&gt;rackup myapp.ru
--&amp;gt; Puma starting in single mode...
--&amp;gt; * Version 4.2.0 (ruby 2.6.5-p114), codename: Distant Airhorns
--&amp;gt; * Min threads: 0, max threads: 16
--&amp;gt; * Environment: development
--&amp;gt; * Listening on tcp://127.0.0.1:9292
--&amp;gt; * Listening on tcp://[::1]:9292
--&amp;gt; Use Ctrl-C to stop
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can access the app by typing in your browser. &lt;a rel=&quot;nofollow&quot; href=&quot;denied:127.0.0.1:9292&quot;&gt;127.0.0.1:9292&lt;/a&gt;.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/24060/web-hello-world-in-ruby-without-ror</guid>
<pubDate>Mon, 03 Aug 2026 21:41:20 +0000</pubDate>
</item>
</channel>
</rss>