Ruby製のコードは以下です。
#!/usr/bin/env ruby
require 'sinatra'
require 'slim'
Slim::Engine.set_options pretty: true
get '/ruby/rand' do
redirect '/ruby/rand/'
end
get '/ruby/rand/' do
slim :index
end
not_found do
slim :not_found
end
__END__
@@ index
doctype html
html
head
title ランダマイザー
body
center
span style="font-size: 5vh;"
-n="\n"
=n
-col=' : '
-sp=' '
-ab=["a","b"]
-for num in 1..10 do
-num0=format('%02d', num)
=num0
=col
-rnd=rand(0..1)
=ab[rnd]
=sp
br
=n
<input type="button" value="もう1回" onclick="window.location.reload(false);" style="font-size: 3vh; WIDTH:25vw ; HEIGHT: 10vh"/>
@@ not_found
doctype html
html
head
title そのURLはコンテンツが存在しません
body
center
span style="font-size: 2vh;"
'そのURLはコンテンツが存在しません。
br
a href="/" トップページに戻ってみてください。
slimのおかげでhtml部分がシンプルになってますけど、
改行とかスペースとかコロンとかが、
slimに処理されてしまうのを防ぐため、
変数に代入して表示させています。