Ruby Web
Every have the urge to use this cool new scripting language for actual server side cgi for your web site? Hate using pre-made CGI API's? Ever know where to look to grab the web variables to hack your own code?
If you said yes to all of the above this is for you! ;)
I said yes and searched the web over for just the right answers. Here's some code for you:
Not the most beautiful code, and I haven't thoroughly tested the post side of the code (I honestly haven't needed to use post yet), but the GET side works perfectly.
I hope I just made someone else's day, by not making them search for 2-3 hours solid through thousands of news group postings (google failed me here big time), so that they can be more productive or just have fun with this language.
Signing Off,
m3talsmith
If you said yes to all of the above this is for you! ;)
I said yes and searched the web over for just the right answers. Here's some code for you:
def getFormRequest
if ENV['REQUEST_METHOD']=='POST'
@request=Hash.new
@vars2=Array.new
vars=$stdin.gets.strip.split('&')
vars.each { |pair| @vars2.push(pair.split('=')) }
@vars2.each { |key,value| @request[key]=value }
end
if ENV['QUERY_STRING']
@request=Hash.new
@vars2=Array.new
vars=ENV['QUERY_STRING'].split('&')
vars.each { |pair| @vars2.push(pair.split('=')) }
@vars2.each { |key,value| @request[key]=value }
end
return @request
end
Not the most beautiful code, and I haven't thoroughly tested the post side of the code (I honestly haven't needed to use post yet), but the GET side works perfectly.
I hope I just made someone else's day, by not making them search for 2-3 hours solid through thousands of news group postings (google failed me here big time), so that they can be more productive or just have fun with this language.
Signing Off,
m3talsmith

