2

これが私のfaxattach.rbコードです:

require 'sinatra'
require 'docsplit'
require './sinatra/faxattach_helpers'

class FaxAttach < Sinatra::Base
  helpers Sinatra::FaxAttachHelpers

      get '/*' do
        "hello world"
        status 405
      end

      put '/*' do
        status 405
      end

      patch '/*' do
        status 405
      end

      delete '/*' do
        status 405
      end

      options '/*' do
        status 405
      end

      link '/*' do
        status 405
      end

      unlink '/*' do
        status 405
      end

      post '/process' do
        path = params[:path]
        begin
          debugger
          file = test_download path
        rescue
          status 404
        end

        debugger
        code = extractCode file
        code
      end

    end

curl を使用して /process への投稿リクエストを行っていますがcurl --data "path=URL_HERE" localhost:4567/process、何らかの理由で取得しています: Sinatra doesn't know this dittypost /processそれは私が明らかに持っているを入れるように言っています。

何か案は?

4

2 に答える 2

4

クラスruby faxattach.rbの最後に次の行を追加すると、モジュラー アプリで使用できます(:

run! if __FILE__ == $0

$0実行ファイルです。

__FILE__現在のファイルです。

例えば:

require "sinatra/base"

class App < Sinatra::Base
  get '/' do
    "App is running."
  end
  # add more endpoints...

  # ...then add run! to run if the
  # file has been executed directly.
  # It should be last.
  run! if __FILE__ == $0
end
于 2013-07-02T01:36:37.313 に答える
2

わかりました。問題は、アプリをruby faxattach.rbではなく で起動していたことですrackup

于 2013-07-01T21:56:07.383 に答える