# Simple ruby web server

**URL:** <https://rubytalk.org/t/simple-ruby-web-server/41175>\
**Category:** ruby-talk\
**Created:** [5 October 2007 01:50 UTC](https://rubytalk.org/t/simple-ruby-web-server/41175 "2007-10-05T01:50:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Filipe](https://avatars.discourse-cdn.com/v4/letter/f/35a633/32.png) [@Filipe](https://rubytalk.org/u/Filipe)\
**Post date:** [5 October 2007 01:50 UTC](https://rubytalk.org/t/simple-ruby-web-server/41175/1 "2007-10-05T01:50:03Z")

</div>

Hi all,

I'm looking for a simple webserver that could handle basic requests  
(mostly from a localhost) outputing html files. It should also be able  
to get the input from forms. Rails seems too powerful to perform such  
a simple class.

Sorry if this sounds confusing. I'm a newcomer to the ruby language.

---

<div class="post-metadata">

**Author:** ![Konrad\_Meyer](https://avatars.discourse-cdn.com/v4/letter/k/df705f/32.png) [@Konrad\_Meyer](https://rubytalk.org/u/Konrad_Meyer)\
**Post date:** [5 October 2007 02:09 UTC](https://rubytalk.org/t/simple-ruby-web-server/41175/2 "2007-10-05T02:09:47Z")

</div>

Quoth Filipe:

> Hi all,
> 
> I'm looking for a simple webserver that could handle basic requests  
> (mostly from a localhost) outputing html files. It should also be able  
> to get the input from forms. Rails seems too powerful to perform such  
> a simple class.
> 
> Sorry if this sounds confusing. I'm a newcomer to the ruby language.

Look into WEBrick / GServer.

> **···**
>
> --  
> Konrad Meyer \<konrad@tylerc.org\> [http://konrad.sobertillnoon.com/](http://konrad.sobertillnoon.com/)

---

<div class="post-metadata">

**Author:** ![James\_Britt](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@James\_Britt](https://rubytalk.org/u/James_Britt)\
**Post date:** [5 October 2007 04:24 UTC](https://rubytalk.org/t/simple-ruby-web-server/41175/3 "2007-10-05T04:24:10Z")

</div>

Rails isn't a web server.  
Apache is a web server.  
Rails is (like any web framework) a glorified CGI program.  
There is Merb, and Camping, and Ruby does have a CGI class...

> **···**
>
> On Oct 4, 2007, at 8:50 PM, Filipe wrote:
> 
> > Hi all,
> > 
> > I'm looking for a simple webserver that could handle basic requests  
> > (mostly from a localhost) outputing html files. It should also be able  
> > to get the input from forms. Rails seems too powerful to perform such  
> > a simple class.
> > 
> > Sorry if this sounds confusing. I'm a newcomer to the ruby language.

---

<div class="post-metadata">

**Author:** ![dusty](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@dusty](https://rubytalk.org/u/dusty)\
**Post date:** [5 October 2007 04:05 UTC](https://rubytalk.org/t/simple-ruby-web-server/41175/4 "2007-10-05T04:05:07Z")

</div>

#!/bin/env ruby  
require 'webrick'  
include WEBrick

s = HTTPServer.new(  
&nbsp;&nbsp;:Port =\> 2000,  
&nbsp;&nbsp;:DocumentRoot =\> Dir::pwd  
)

trap("INT"){ s.shutdown }  
s.start

Run that in a directory with html files. That will serve them up for  
ya, then go from there.

If you want a small mvc pattern, then check out camping. A little  
more in-depth but smaller than rails is merb. I prefer merb myself.

> **···**
>
> On Oct 4, 10:09 pm, Konrad Meyer \<kon...@tylerc.org\> wrote:
> 
> > Quoth Filipe:
> > 
> > \> Hi all,
> > 
> > \> I'm looking for a simple webserver that could handle basic requests  
> > \> (mostly from a localhost) outputing html files. It should also be able  
> > \> to get the input from forms. Rails seems too powerful to perform such  
> > \> a simple class.
> > 
> > \> Sorry if this sounds confusing. I'm a newcomer to the ruby language.
> > 
> > Look into WEBrick / GServer.
> > 
> > --  
> > Konrad Meyer \<kon...@tylerc.org\>[http://konrad.sobertillnoon.com/](http://konrad.sobertillnoon.com/)
> > 
> > signature.asc  
> > 1KDownload

---

<div class="post-metadata">

**Author:** ![James\_Britt3](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@James\_Britt3](https://rubytalk.org/u/James_Britt3)\
**Post date:** [5 October 2007 05:15 UTC](https://rubytalk.org/t/simple-ruby-web-server/41175/5 "2007-10-05T05:15:24Z")

</div>

dusty wrote:

> If you want a small mvc pattern, then check out camping. A little  
> more in-depth but smaller than rails is merb. I prefer merb myself.

Also look at Nitro and Ramaze, both of which make it quite simple to develop Web sites using a range of techniques, from all-in-one-file to full-blown MVC, with or without a database.

> **···**
>
> --  
> James Britt
> 
> "Every object obscures another object."  
> &nbsp;&nbsp;&nbsp;&nbsp;- Luis Bunuel

---

<div class="post-metadata">

**Author:** ![Filipe](https://avatars.discourse-cdn.com/v4/letter/f/35a633/32.png) [@Filipe](https://rubytalk.org/u/Filipe)\
**Post date:** [6 October 2007 01:35 UTC](https://rubytalk.org/t/simple-ruby-web-server/41175/6 "2007-10-06T01:35:05Z")

</div>

Webrick seems to be what I'm looking for. However I couldn't find any  
tutorial/sample or documentation for it. Is there any sample avaliable  
on the web?

> **···**
>
> On Oct 5, 2:15 am, James Britt \<james.br...@gmail.com\> wrote:
> 
> > dusty wrote:
> > 
> > \> If you want a small mvc pattern, then check out camping. A little  
> > \> more in-depth but smaller than rails is merb. I prefer merb myself.
> > 
> > Also look at Nitro and Ramaze, both of which make it quite simple to  
> > develop Web sites using a range of techniques, from all-in-one-file to  
> > full-blown MVC, with or without a database.
> > 
> > --  
> > James Britt
> > 
> > "Every object obscures another object."  
> > &nbsp;&nbsp;&nbsp;&nbsp;- Luis Bunuel

---

<div class="post-metadata">

**Author:** ![James\_Britt3](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@James\_Britt3](https://rubytalk.org/u/James_Britt3)\
**Post date:** [6 October 2007 02:45 UTC](https://rubytalk.org/t/simple-ruby-web-server/41175/7 "2007-10-06T02:45:29Z")

</div>

Filipe wrote:

> Webrick seems to be what I'm looking for. However I couldn't find any  
> tutorial/sample or documentation for it. Is there any sample avaliable  
> on the web?

[http://segment7.net/projects/ruby/WEBrick/](http://segment7.net/projects/ruby/WEBrick/)

> **···**
>
> --  
> James Britt
> 
> "Those who would give up Essential Liberty to purchase a little  
> Temporary Safety, deserve neither Liberty nor Safety."  
> &nbsp;&nbsp;- Benjamin Franklin, when asked about static typing  
> &nbsp;&nbsp;&nbsp;(and a tip of the hat to raganwald)
