私は最近Rackをいじっていますがapp.rb
、を使用せずにファイル(たとえば)を実行してRackサーバーを起動するにはどうすればよいか疑問に思っていますconfig.ru
。これは可能ですか、それとももっと複雑な方法ですか?
1419 次
1 に答える
3
代わりに、組み込みのWEBrickサーバーを使用できます。したがって、通常は次のようなものがあります。
# app.rb
class App
def call(env)
return [200, {"Content-Type" => "text/html"}, "Hello, World!"]
end
end
# config.ru
require 'app'
run App.new
代わりに、それを統合してruby app.rb
直接実行することができます。
#app.rb
class App
def call(env)
return [200, {"Content-Type" => "text/html"}, "Hello, World!"]
end
end
Rack::Handler::WEBrick.run(App.new, :Port => 9292)
于 2012-04-27T22:25:15.380 に答える