(ruby)使用Sinatra

首先使用bundle初始化一个项目:

$ bundle init
Writing new Gemfile to /Users/weli/works/sinatra-foo/Gemfile

添加sinatra

$ bundle add sinatra
Fetching gem metadata from https://rubygems.org/....
Resolving dependencies...
...
Installing sinatra 2.0.8.1
$

查看Gemfile里面添加的依赖:

$ cat Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"

gem "sinatra", "~> 2.0"
$

撰写一个sinatra的代码:

启动服务:

访问服务:

本文用到的项目:

Powered by Jekyll and Theme by solid