尝试了解如何在 Ebb Web 服务器上运行 Ruby (Sinatra) 应用程序

发布于 2024-07-25 05:42:13 字数 171 浏览 1 评论 0原文

我需要编写一个超快速的 Ruby 应用程序来处理 Sinatra 上的 Web 请求 - 并希望在 Ebb Webserver。 但我不知道如何做到这一点。 有人可以帮我吗?

I need to write a super fast Ruby application to process web requests on Sinatra - and want to run it on the Ebb webserver. But I cannot work out how to do this. Could someone please help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一身仙ぐ女味 2024-08-01 05:42:13

sinatra 有一个 -s 选项来指定处理程序。 尝试使用 -s ebb 运行您的应用程序。

sinatra has a -s option to specify a handler. try running your app with -s ebb.

拿命拼未来 2024-08-01 05:42:13

您需要查看 Rack:http://rack.rubyforge.org/
这确实很简单,您有一个 .ru 文件,它指示 Rack 如何启动您的应用程序,并且在您的应用程序中,您有一个“调用”方法,该方法在每个请求上调用,并将响应发送回 Rack。

在 my_app.ru

require 'my_app'
require 'ebb'

# Rack config
use Rack::Static, urls: ['/js', '/public', '/index.html']
use Rack::ShowExceptions

# Run application
run MyApp.new

在 my_app.rb

class MyApp
 def call env
    request  = Rack::Request.new env
    response = Rack::Response.new
    params = request.params

    response.body = "Hello World"
    response['Content-Length'] = response.body.size.to_s
    response.finish
  end
end

然后您在 sinatra 配置中指定 .ru 文件,例如:

rackup: my_app.ru

You need to look at Rack: http://rack.rubyforge.org/
It's pretty easy really, you have a .ru file which instructs Rack how to start your application, and in your application you have a 'call' method which is called on each request, and sends the response back to Rack.

In my_app.ru

require 'my_app'
require 'ebb'

# Rack config
use Rack::Static, urls: ['/js', '/public', '/index.html']
use Rack::ShowExceptions

# Run application
run MyApp.new

In my_app.rb

class MyApp
 def call env
    request  = Rack::Request.new env
    response = Rack::Response.new
    params = request.params

    response.body = "Hello World"
    response['Content-Length'] = response.body.size.to_s
    response.finish
  end
end

Then you specify the .ru file in your sinatra config, like:

rackup: my_app.ru
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文