English 中文(简体)
如何利用废墟从超文本箱返回?
原标题:How to receive return from HTML textbox using ruby?
  • 时间:2011-02-18 00:08:16
  •  标签:
  • ruby

我正在Rub建立聊天客户/服务器系统。

我的服务器将安装在一台膝上型计算机或某种材料上(这是一个班级项目,因此不需要多少加处理能力),然后我计划在网上浏览器上安装客户。

我将向它提供两种文本箱的超文本:一种是用户能够打造的,另一种是显示聊天历史。

My problem is that while I can easily feed the HTML code to the browser and get it to display the chat (navigate to the ip address:port) I can t figure out how I can return what is input in the textbox to the server.

没有人知道我如何能够这样做?

最佳回答

你们需要基本知识,了解农研中心的工作方式。 一旦你知道,你会发现更容易与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上建起更方便地提供更多的特征,而不是与全方位地理信息公司一道提供。

问题回答

我建议使用一个轻重框架,如Sinatra来处理这一问题。 如果你想要的话,它只是简单地迅速做事,而无需经过很多必要的阅读,但如果你想要的话,它就足够强大,可以大大扩大你的聊天申请。

The downside of using a web-based client is that the chat log will only be refreshed on the client after they ask the server for the newest information; namely, at each page refresh, instead of in real time.

你们可以通过一些浮标(主要是XMLTPRequest定期要求新内容,例如Stack Overflow如何在新答复被贴上你自己回答打字。





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...