你们需要基本知识,了解农研中心的工作方式。 一旦你知道,你会发现更容易与Sinatra合作,正如“Echoback”建议的那样,或与Paderino、铁路或与其他语言合作。
This is a pretty basic CGI. It generates a simple form, along the lines of what you were talking about, then walks through the environment table passed to Ruby by the web server, sorts by the keys, and outputs a table in sorted order. Most of the fields directly apply to either the web server itself, or to the CGI, such as the query sent by the browser, along with its headers sent to the server saying what its capabilities are:
#!/usr/bin/env ruby
puts "Content-Type: text/html"
puts
puts "<html><head><style type= text/css >body{font-family: monospace;}</style></head><body>"
puts "<form name= foo action= test_cgi.rb >"
puts "<input type= textinput name= inputbox ></input><br />"
puts "<textarea name= textareabox ></textarea><br />"
puts "<input type= submit ></input>"
puts "</form>"
puts "<h4>ENVIRONMENT:</h4>"
puts "<table>"
ENV.keys.sort.each do |k|
puts "<tr><td>#{k}</td><td>#{ENV[k]}</td></tr>"
end
puts "</table>"
puts "</body></html>"
该代码将其储存在一份名为的Ruby文档中,然后将可起诉的借方放在档案上。 将该文档输入cgi-bin
>。 利用您的浏览器查阅档案(http:// localhost:80/cgi-bin/test_cgi.rb
或其他类似内容),并在表格中看到产出,因为你以表格形式输入不同的数值并提交这些数值。
一旦你们理解,从服务器到浏览器到服务器的四舍五入,就能够很好地了解Sinatra如何在Rack上建起更方便地提供更多的特征,而不是与全方位地理信息公司一道提供。