HTML posting to ruby script?

B

Brad Mr

Ok new to Ruby.

I have an HTML form that I want a user to enter data, and when the
SUBMIT button is pressed, the HTML POST (with the data) goes to a Ruby
script to process the data (no web server running) into ruby variables
to be used in other Ruby Scripts.

Again this is meant to be able to run offline because ultimately this is
all going into the "Titanium" app runtime (Similar to adobe AIR, but
Ruby and Python runtimes are included), and like AIR can run on any
platform.

In short it becomes a multi-platform desktop app using HTML as the GUI.

Question is, how do I get that ruby script to accept the POST and pull
the data out to make the variables?
 
K

Kent Friis

Den Sat, 22 Aug 2009 15:07:33 -0500 skrev Brad Mr:
Ok new to Ruby.

I have an HTML form that I want a user to enter data, and when the
SUBMIT button is pressed, the HTML POST (with the data) goes to a Ruby
script to process the data (no web server running) into ruby variables
to be used in other Ruby Scripts.

Again this is meant to be able to run offline because ultimately this is
all going into the "Titanium" app runtime (Similar to adobe AIR, but
Ruby and Python runtimes are included), and like AIR can run on any
platform.

In short it becomes a multi-platform desktop app using HTML as the GUI.

Question is, how do I get that ruby script to accept the POST and pull
the data out to make the variables?

You need a webserver. Can be a simple one, can even be written in
Ruby, but you do need one.

/Kent
 
7

7stud --

Brad said:
Ok new to Ruby.

I have an HTML form that I want a user to enter data, and when the
SUBMIT button is pressed, the HTML POST (with the data) goes to a Ruby
script to process the data (no web server running) into ruby variables
to be used in other Ruby Scripts.

Again this is meant to be able to run offline

Web pages have no access to the local file system--for security reasons.
You wouldn't be able to browser the internet if a web page could
suddenly flood every folder on your computer with thousands of
advertisements. And you say that the web browser is offline, which
means the web page can't communicate with a server. So the question is:
where is the ruby script located? You see the dilemma?
 
B

Brian Candler

Brad said:
In short it becomes a multi-platform desktop app using HTML as the GUI.

You need a small webserver, which can be bound to 127.0.0.1 (so that
browsers on remote machines cannot access it). You would then point your
browser at http://127.0.0.1:xxxx/ where xxxx is whatever port you bound
the webserver to.

Sinatra looks to be a very good match to your requirements.

require 'rubygems'
require 'sinatra'
post '/submit' do
.. do stuff using posted params[]
.. return a string containing the response page
end
 
B

Brad Mr

7stud said:
Web pages have no access to the local file system--for security reasons.
You wouldn't be able to browser the internet if a web page could
suddenly flood every folder on your computer with thousands of
advertisements. And you say that the web browser is offline, which
means the web page can't communicate with a server. So the question is:
where is the ruby script located? You see the dilemma?

If that is true then how does Javascript work if you make all function
definition in a single seperate *.js file while, calls to its function,
and you don't need a web server for that?
 
K

Kent Friis

Den Mon, 24 Aug 2009 09:17:56 -0500 skrev Brad Mr:
If that is true then how does Javascript work if you make all function
definition in a single seperate *.js file while, calls to its function,
and you don't need a web server for that?

Javascript runs in the browser.

/Kent
 
M

Mike Stephens

Brad said:
(no web server running)

A program that handles http messages is called a web server so you have
to have one. The simplest solution is to use the normal Ruby web server
options, running locally as mentioned in another post. Why did you
decide you wanted to avoid this approach?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,192
Latest member
KalaReid2

Latest Threads

Top