ruby - 如何更改sinatra 的host?
天蓬老师
天蓬老师 2017-04-21 11:15:26
0
1
654

完全不了解web 开发 买了个vps 想自己试试, 想用sinatra 写个web service

require 'sinatra' 
get '/'do 
"Just Do It" 
server = ::Thin::Server.new(options[:Host] || '106.3.38.47', 
options[:Port] || 996, 
app) 
end 

我想吧 sinatra 的Demo 跑在我的VPS上,应该如何做啊,106.3.38.47:996无法访问,localhost:4567 可以,求指导

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
巴扎黑

See the official document config.ru

Use config.ru to run traditional applications Write your app:

# app.rb
require 'sinatra'

get '/' do
  'Hello world!'
end

Add the corresponding config.ru:

require './app'
run Sinatra::Application

When to use config.ru? You may need to use config.ru:

  • You need to use different Rack processor deployment (Passenger, Unicorn, Heroku, …).

  • You want to use one or more subclasses of Sinatra::Base.

  • You only want to use Sinatra as a middleware, not an endpoint.

You don’t need to switch to config.ru just because you switch to modular mode, and you don’t need to switch to modular mode just to run config.ru.

Then, you need to use thin或者Passenger,unicornetc. web server to run your program

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template