# Simple ruby web server

**URL:** <https://www.ruby-forum.com/t/simple-ruby-web-server/116388>\
**Category:** Ruby\
**Created:** [October 5, 2007, 3:50am UTC](https://www.ruby-forum.com/t/simple-ruby-web-server/116388 "2007-10-05T03:50:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Filipe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/35a633/32.png) [@Filipe](https://www.ruby-forum.com/u/Filipe)\
**Post date:** [October 5, 2007, 3:50am UTC](https://www.ruby-forum.com/t/simple-ruby-web-server/116388/1 "2007-10-05T03:50:44Z")

</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:** ![Filipe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/35a633/32.png) [@Filipe](https://www.ruby-forum.com/u/Filipe)\
**Post date:** [October 5, 2007, 4:10am UTC](https://www.ruby-forum.com/t/simple-ruby-web-server/116388/2 "2007-10-05T04:10:36Z")

</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.

---

<div class="post-metadata">

**Author:** ![Filipe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/35a633/32.png) [@Filipe](https://www.ruby-forum.com/u/Filipe)\
**Post date:** [October 5, 2007, 6:05am UTC](https://www.ruby-forum.com/t/simple-ruby-web-server/116388/3 "2007-10-05T06:05:47Z")

</div>

On Oct 4, 10:09 pm, Konrad M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Look into WEBrick / GServer.
> 
> –  
> Konrad M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[http://konrad.sobertillnoon.com/](http://konrad.sobertillnoon.com/)
> 
> signature.asc  
> 1KDownload

#!/bin/env ruby  
require ‘webrick’  
include WEBrick

s = HTTPServer.new(  
:Port =\> 2000,  
: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.

---

<div class="post-metadata">

**Author:** ![Filipe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/35a633/32.png) [@Filipe](https://www.ruby-forum.com/u/Filipe)\
**Post date:** [October 5, 2007, 6:24am UTC](https://www.ruby-forum.com/t/simple-ruby-web-server/116388/4 "2007-10-05T06:24:32Z")

</div>

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.

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…

---

<div class="post-metadata">

**Author:** ![Filipe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/35a633/32.png) [@Filipe](https://www.ruby-forum.com/u/Filipe)\
**Post date:** [October 5, 2007, 7:15am UTC](https://www.ruby-forum.com/t/simple-ruby-web-server/116388/5 "2007-10-05T07:15:59Z")

</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 B.

“Every object obscures another object.”  
- Luis Bunuel

---

<div class="post-metadata">

**Author:** ![Filipe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/35a633/32.png) [@Filipe](https://www.ruby-forum.com/u/Filipe)\
**Post date:** [October 6, 2007, 4:46am UTC](https://www.ruby-forum.com/t/simple-ruby-web-server/116388/6 "2007-10-06T04:46:25Z")

</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 B.

“Those who would give up Essential Liberty to purchase a little  
Temporary Safety, deserve neither Liberty nor Safety.”

- Benjamin Franklin, when asked about static typing  
(and a tip of the hat to raganwald)

---

<div class="post-metadata">

**Author:** ![Filipe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/35a633/32.png) [@Filipe](https://www.ruby-forum.com/u/Filipe)\
**Post date:** [October 6, 2007, 3:35am UTC](https://www.ruby-forum.com/t/simple-ruby-web-server/116388/7 "2007-10-06T03:35:37Z")

</div>

On Oct 5, 2:15 am, James B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> James B.
> 
> “Every object obscures another object.”  
> - Luis Bunuel

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?
