开发者

Sinatra: What's the correct way to serve a plain old file?

This works, but it was a stab in the dark. I know little Ruby.

What's the accepted way to serve a plain old file for a given resource?

get '/xyz' do
    File.read 'ab开发者_开发知识库c.html'
end


you can use set :public to specify the directory for your static files. Then, you can serve the file using send_file() for example:

    get '/static_file' do
      send_file('my_static_file')
   end 


Serve it out of the ./public directory. See the Static Files section of the README and the :static and :public configuration options.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜