2013-02-18 2 views
1

나는 Webrick + CGI을 사용하고 내가 인스턴스화 할 때, 오류를 반환했습니다 : (offline mode: enter name=value pairs on standard input)루비 오류 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) 

답변

4

아니,하지 오류가. 그것이 작동하는 방식입니다. 당신이 값을 입력하기 위해 IRB 콘솔에서 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

에서

(offline mode: enter name=value pairs on standard input) 메시지 후, 콘솔이 기다리고 있습니다. key value pairs을 입력 한 다음 을 입력하고 데이터 입력을 마치려면 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 

=> #<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 작업의 상기 코드 예제 CGI Programming Documentation on PLEAC-Ruby 참조 Ctrl 키D. Win7에 +에 WEBrick 서버를 사용

+0

되 잖아, 내 코드는 다음과 같습니다 <% Encoding.compatible % ("\ XA1"("ISO-8859-1"), "B".force_encoding)?> Sessão

zezzão

CGI :: Session.new (cgi, "prefix"=> "rubysession") = "Darlan" %> <% = "오이, 세션 # {["이름 "]}"%> <% session.close 것은 Session.delete %> –

+0

I가 CRTL 사용할 때마다 + D? –