开发者

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

开发者 https://www.devze.com 2022-12-18 23:49 出处:网络
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?

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

精彩评论

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