-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsinatra.sh
66 lines (48 loc) · 1.09 KB
/
sinatra.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Declare site in YAML, as documented on the documentation: https://help.alwaysdata.com/en/marketplace/build-application-script/
# site:
# ruby_version: '3.3'
# type: 'ruby_rack'
# working_directory: '{INSTALL_PATH_RELATIVE}'
# path: '{INSTALL_PATH_RELATIVE}/config.ru'
# path_trim: true
# requirements:
# disk: 20
set -e
# http://sinatrarb.com/documentation.html
cat << EOF > Gemfile
source "http://rubygems.org"
gem 'sinatra', '3.2.0', require: 'sinatra/base'
gem 'sinatra-reloader', require: 'sinatra/reloader'
EOF
bundle install --path vendor/bundle
cat << EOF > server.rb
# Requires the Gemfile
require 'bundler' ; Bundler.require
# Sinatra server
module Server
class App < Sinatra::Base
register Sinatra::Reloader
get '/' do
erb :index
end
end
end
EOF
cat << EOF > config.ru
require './server.rb'
run Server::App
EOF
mkdir views
cat << EOF > views/index.erb
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<p>Today is <%= Time.now.strftime('%A') %></p>
</body>
</html>
EOF