在 Ruby 中,如何打印 URL 参数和服务器环境变量?
在 Ruby(作为 .cgi 在 Web 服务器上运行)中,如何打印 URL 参数和服务器环境变量(最好不使用任何包)? (以最原始的形式)
In Ruby (running on a web server as a .cgi), how do you print out the URL params and Server environment variables, preferable without using any package? (by the rawest form)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这些通过环境变量传递给 Ruby 解释器本身;因此您可能需要使用
cgi
包来获取它们。例如:有关更多信息,请查看 CGI 文档 http:// www.ruby-doc.org/stdlib/libdoc/cgi/rdoc/index.html
(顺便说一句,apache 使用的 mod-ruby 有缺陷;如果你想走自己的路,你应该尝试 Mongrel 和 Rack反对使用 Rails 或 Merb。)
These are passed to the Ruby interpreter itself via env variables; so you'll probably want to use the
cgi
package to get at them. E.g.:For more, view the CGI documentation at http://www.ruby-doc.org/stdlib/libdoc/cgi/rdoc/index.html
(BTW, mod-ruby that apache uses is flawed; you should try out Mongrel and Rack if you wanna go your own way as opposed to using Rails or Merb.)
谢谢你的回答。我还在cgi包代码中发现了一些内容,该变量
可以用来显示所有服务器变量。即使在 shell 或命令提示符中运行 ruby 或 irb,它也包含环境变量。
thanks for the answer. I also found something in the cgi package code that the variable
can be used to show all server variables. It contains environment variables even if running ruby or irb in a shell or command prompt.