0
我已經使用Nginx 1.12.1設置了Ubuntu 16.04服務器並且安裝並配置了Phusion Passenger 5.1.8(開源)以正常工作。Nginx不能使用Sinatra JSON路由
我已經用passenger-ruby-sinatra-demo回購測試了這個。
我已經設置了root
VAR到回購的/views
文件夾中的文件/etc/nginx/sites-available/default
:
root /var/www/passenger-ruby-sinatra-demo/views;
的/views
文件夾包含一個文件調用index.erb
。參觀時/
我看到html頁面
require 'sinatra/base'
require 'json'
class ExampleApp < Sinatra::Base
get '/' do
erb :index
end
get '/hello' do
content_type 'application/json'
{'message'=>'hello world!'}.to_json
end
end
所以現在:
這裏是app.rb
文件的內容。但是當訪問/hello
時,我得到一個404屏幕。
我在做什麼錯?
更新: 當我在views
文件夾中添加名爲hello
的空文件夾時,它確實有效。