gpt4 book ai didi

Ruby 错误 Webrick 或 CGI?

转载 作者:数据小太阳 更新时间:2023-10-29 08:32:54 25 4
gpt4 key购买 nike

我使用了 Webrick + CGI,当我实例化时,返回一个错误:(离线模式:在标准输入上输入名称=值对)

irb(main):001:0> require 'cgi'
=> true
irb(main):002:0> cgi = CGI.new
(offline mode: enter name=value pairs on standard input)

最佳答案

不,不是错误。这就是它的工作方式。

来自ruby-docs CGI documentation

If the CGI object is not created in a standard CGI call environment (that is, it can’t locate REQUEST_METHOD in its environment), then it will run in “offline” mode. In this mode, it reads its parameters from the command line or (failing that) from standard input

在 irb 控制台中,在 (离线模式:在标准输入上输入名称=值对) 消息之后,控制台正在等待您输入值。输入键值对,然后按Ctrld 完成数据输入。

 irb(main):001:0> require 'cgi'
=> true
irb(main):002:0> cgi = CGI.new
(offline mode: enter name=value pairs on standard input)
name=Prakash
number=432

Ctrld

 => #<CGI:0x007fa4eb2abd30 @options={:accept_charset=>"UTF-8"}, @accept_charset="UTF-8", @multipart=false, @params={"name"=>["Prakash"], "number"=>["432"]}, @cookies={}, @output_cookies=nil, @output_hidden=nil> 
irb(main):003:0>

引用CGI Programming Documentation on PLEAC-Ruby有关在 ruby​​ 中使用 CGI 的更多代码示例。

关于Ruby 错误 Webrick 或 CGI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14929260/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com