Static page routing in Sinatra (Ruby)

前端 未结 6 874
醉酒成梦
醉酒成梦 2021-02-13 13:39

You can serve static files with Sinatra by placing them in public/ (by default) -- I have an index.html in there at the moment, but how can I make the

6条回答
  •  故里飘歌
    2021-02-13 14:25

    Probably a better answer will eventually come, until then this is my shot at it.

    If this is not what you want:

    get '/' do
      redirect '/index.html'
    end
    

    You might do something like this:

    get '/' do
      File.new('public/index.html').readlines
    end
    

    I'd go with the first one though, Not sure why you want to avoid that redirect

提交回复
热议问题