§2023-02-27
2.3. Creating Our First Sinatra API
- mkdir master_ruby_web_apis
$ mkdir master_ruby_web_apis && cd $_
$ bundler init
$ nano Gemfile --> gem 'sinatra'
$ bundler install
Fetching gem metadata from https://rubygems.org/....
Resolving dependencies...
Using bundler 2.4.6
Using rack 2.2.6.2
Using tilt 2.1.0
Using ruby2_keywords 0.0.5
Using rack-protection 3.0.5
Using mustermann 3.0.0
Using sinatra 3.0.5
Bundle complete! 1 Gemfile dependency, 7 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
mkdir module_01 && cd $_
in master_ruby_web_apis- nano webapi.rb as,
# webapi.rb
require 'sinatra'
get '/' do
'Master Ruby Web APIs - Chapter 2'
end
- run it
ruby webap.rb
2.4.1. URL, URI, IRI, URN, …