[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby without rails as a web server

yovav9

7/1/2007 9:18:00 PM

Hi
I need to write a server that receives requests from clients, does
some processing and return answers.
For simplicity and firewall-tolerance, we've decided on HTTP as the
baseline protocol:
the client will send a request embedded in the query part of the URL,
and the server will return the response as text over HTTP.
We have Apache, and since we want an OO server, we're considering Ruby
(without Rails).
However, when putting an .rb file in the htdocs, the browser keeps
trying to open the file, instead of the server processing the content.
1. What are we doing wrong?
2. How can we access the client request (URL query, and possibly text)
from the Ruby script?

Thanks

3 Answers

Phlip

7/1/2007 10:08:00 PM

0

yovav9 wrote:

> I need to write a server that receives requests from clients, does
> some processing and return answers.
> For simplicity and firewall-tolerance, we've decided on HTTP as the
> baseline protocol:
> the client will send a request embedded in the query part of the URL,
> and the server will return the response as text over HTTP.
> We have Apache, and since we want an OO server, we're considering Ruby
> (without Rails).
> However, when putting an .rb file in the htdocs, the browser keeps
> trying to open the file, instead of the server processing the content.
> 1. What are we doing wrong?

http://www.google.com/search?q=ruby+sheb...

The secret word was "shebang". That's jargon for the #! line (shell-bang) at
the top of the root .rb document. Set it to #!/usr/bin/env ruby , and mark
the .rb file as executable, and then declare the Ruby as a CGI handler
within the maze of Apache's httpd.conf and .htaccess files.

> 2. How can we access the client request (URL query, and possibly text)
> from the Ruby script?

They arrive in the ENV[] hash, and you require 'cgi' to automatically parse
them out into available variables.

Tip: Use Webrick in its CGI mode as a mini-apache. It will configure
generally the same, and you don't need to use apache each time you develop.

Tip two: Use Rails. You have a wheel-reinventing thing going, and Rails in
its simplest and leanest modes will do fine for simple CGI responses.

--
Phlip
http://www.oreilly.com/catalog/9780...
"Test Driven Ajax (on Rails)"
assert_xpath, assert_javascript, & assert_ajax


yovav9

7/2/2007 5:20:00 AM

0

Thanks Philip,
But I seem to have forgotten to mention a crucial fact - I'm running
on Windows and not Linux/Unix...

docremington

9/11/2010 9:45:00 AM

0



Dakota wrote:
> On Mon 9/6/10 23:24, J:
> > [some drivel]
>
> As the pre-1967 borders are now recognized, Israel would rightly claim
> all but East Jerusalem as its own. East Jerusalem, as part of the West
> Bank, would be sovereign Jordanian territory.
>

Can we, sincerely, expect the US returning Texas to Mexico?