LoginSignup
10
13

More than 5 years have passed since last update.

Sinatra で get '/*/' 時に public/*/index.html を返す

Last updated at Posted at 2012-12-26
app.rb
require 'sinatra'

get '/' do
  send_file File.join(settings.public_folder, 'index.html')
end

get '/*/' do |path|
  send_file File.join(settings.public_folder, path, 'index.html')
end

参考

課題

http://localhost:4567/a/b/ とすれば public/a/b/index.html が取れるのはいいが http://localhost:4567/a/b でも同様に動作して欲しい.さてどうしようかな?

所感

主な目的が静的な HTML ファイルのサーバなのだが,それに Sinatra を選んでいるのがそもそも間違いか?
Heroku を使ってやりたいので安直に Sinatra を選んだのだが Sinatra 以外,Heroku 以外に何か選択肢は無いか?

10
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
13