Deploy Sinatra app on Heroku

前端 未结 5 684
后悔当初
后悔当初 2020-12-23 14:58

I have simple Sinatra app.

web.rb:

require \'sinatra\'

get \'/\' do 
    \"Hello\" 
end

Gemfile:*

5条回答
  •  再見小時候
    2020-12-23 15:51

    Here's how to create a minimal sinatra app that deploys to heroku:

    app.rb:

    require 'sinatra'
    
    get '/' do
      "hello world"
    end
    

    Gemfile:

    source 'https://rubygems.org'
    
    gem 'heroku'
    gem 'sinatra'
    gem 'thin'
    

    config.ru:

    require './app'
    run Sinatra::Application
    

    Type these commands in your command line to deploy (without the $ signs):

    $ bundle install
    $ git init
    $ git add -f app.rb Gemfile Gemfile.lock config.ru
    $ git commit -am "initial commit"
    $ heroku create 
    $ git push heroku master
    

    Then test your app:

    $ curl .heroku.com
    

    and you should see:

    hello world
    

提交回复
热议问题