我正在嘗試將信息從文本表單移動到使用CGI的新網頁。爲此,我在表格中將action
設置爲action="new.html"
。然後,在我的.rb
文件的相關部分,我有:如何在使用Ruby和Sinatra編寫的Heroku應用程序中使用CGI?
get "/new.html" do
@graph = Koala::Facebook::API.new(session[:access_token])
@app = @graph.get_object(ENV["FACEBOOK_APP_ID"])
if session[:access_token]
@query=CGI.new() # Line of interest
@[email protected]["tool_1"] # Line of interest
end
erb :my_tools_F
end
post "/new.html" do
redirect "/new.html"
end
新的Web頁面加載,但@input
是空白的,當我把它在.erb
文件。在這部分腳本之前,我確實需要CGI。我的網絡主機是Heroku,並且.erb
文件都位於名爲views
的目錄中。該應用程序構建在Facebook上推出。
示例代碼是here。
我更新了我的答案。看看它是否可以幫助你。 – sunnyrjuneja