使用ruby rack提交表单

时间:2015-07-31 10:35:39

标签: ruby-on-rails ruby rack

我正在尝试开发基于机架的Web应用程序

config.ru

"name"

home.html

use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "Rack"
run lambda { |env|
[
 200,
{
  'Content-Type'  => 'text/html',
  'Cache-Control' => 'public, max-age=86400'
},
File.open('home.html', File::RDONLY)
]
}

和ruby文件 Rack.rb

<form action="Rack.rb" method="get">
  name: <input type="text" name="name"><br>
  age: <input type="text" name="age"><br>
  <input type="submit" value="Submit">
</form>

输出

require 'rack'
require 'rack/server'

class HelloWorld
 def response
  [200, {}, ['Hello World']]
 end
end

class HelloWorldApp
 def self.call(env)
   HelloWorld.new.response
 end
end

Rack::Server.start :app => HelloWorldApp

我需要解析GET请求的输入。怎么做?

0 个答案:

没有答案