2009-04-17 95 views
0

我尝试创建一个test.rb文件,将其放在公共目录中,然后将其命名为http://localhost:3000/test.rb,但似乎不起作用。它认为我正在尝试下载该文件。我在这里错过了什么?小脚本如下:如何在Windows上的Rails上编写Ruby CGI

#!/usr/local/bin/ ruby 
print "HTTP/1.0 200 OK\r\n" 
print "Content-type: text/html\r\n\r\n" 
print "<html><body>Hello World!</body></html>\r\n" 
+0

你想做什么?如果你已经使用Rails,为什么要编写一个CGI? – Petros 2009-04-17 18:31:43

+0

有时我只想写一个快速的CGI,而不是处理一堆MVC的东西等...... – jtruelove 2009-04-17 20:05:26

回答

1

有一个小的http守护进程服务器,我用这种东西。我从来没有听说过你可以配置任何浏览器来为你执行脚本,所以你可能会遇到与我的类似的设置:

你可以找到shttpd(现在叫做mongoose, )在sourceforge。我使用的配置文件为我的红宝石应用程序是这样的:

# SHTTPD web server configuration file. 
# Lines starting with '#' and empty lines are ignored. 
# For detailed description, visit http://shttpd.sourceforge.net/shttpd.1.txt 

#platform-specific stuff 
root   c:\main\src\worker\http 
systray   no 
access_log  logs\shttpd_access_log.txt 
error_log  logs\shttpd_error_log.txt 
cgi_env   RUBYLIB=c:\main\src\worker;c:\main\src\worker\lib 
cgi_interp  c:\InstantRails\ruby\bin\ruby.exe 


#platform-dependant stuff 
ports   2001 
cgi_ext   rb 
threads   5 
index_files  index.rb 

如果您有任何问题,只需更新,我会尽量保持眼睛的线程上。