rack

Streaming data from Sinatra/Rack application

筅森魡賤 提交于 2019-11-26 15:52:33
问题 I am trying to stream textual data (XML/JSON) from a Ruby (1.9.1p378) Sinatra (1.0) Rack (1.2.1) application. The suggested solutions (e.g. Is there a way to flush html to the wire in Sinatra) do not seem to work - the server just blocks when I yield elements of some infinite stream (e.g. from %w(foo bar).cycle ). I tried webrick and thin as servers. Any suggestions on getting this done? Should I use http://sinatra.rubyforge.org/api/classes/Sinatra/Streaming.html and if so how would I use it

HTML5 video will not loop

∥☆過路亽.° 提交于 2019-11-26 15:48:00
I have a video as a background to a web page, and I am trying to get it to loop. Here is the code: <video autoplay='true' loop='true' muted='true'> <source src='/admin/wallpapers/linked/4ebc66e899727777b400003c' type='video/mp4'></source> </video> Even though I have told the video to loop, it does not. I also tried to get it to loop with the onended attribute (as per this Mozilla support thread , I also tried that bit of jQuery). Nothing has worked so far. Is it an issue with Chrome, or my code? Edit: I checked the Network events and HEAD of a working copy ( http://fhsclock-labs.heroku.com/no

Use Rack::CommonLogger in Sinatra

放肆的年华 提交于 2019-11-26 15:24:46
问题 I have a small web-server that I wrote with Sinatra. I want to be able to log messages to a log file. I've read through http://www.sinatrarb.com/api/index.html and www.sinatrarb.com/intro.html, and I see that Rack has something called Rack::CommonLogger, but I can't find any examples of how it can be accessed and used to log messages. My app is simple so I wrote it as a top-level DSL, but I can switch to subclassing it from SinatraBase if that's part of what's required. 回答1: Rack:

Logging in Sinatra?

爷,独闯天下 提交于 2019-11-26 15:23:33
问题 I'm having trouble figuring out how to log messages with Sinatra. I'm not looking to log requests, but rather custom messages at certain points in my app. For example, when fetching a URL I would like to log "Fetching #{url}" . Here's what I'd like: The ability to specify log levels (ex: logger.info("Fetching #{url}") ) In development and testing environments, the messages would be written to the console. In production, only write out messages matching the current log level. I'm guessing this

How do you configure WEBrick to use SSL in Rails?

人走茶凉 提交于 2019-11-26 07:31:24
问题 Prior to Rails 3, you could modify the script/server file to add in SSL parameters and tell the server command to use the HTTPS version of WEBrick. Now that all of those scripts are gone, does anyone know how to get this to work with Rails 3 or 4? 回答1: While the scripts directory in Rails 4 is gone, the bin directory remains. You can get WEBrick working with an SSL certificate by editing the bin/rails script. Tested on Rails 4 and Ruby 2.1.1, installed with rbenv. Much of this is from this

What is Rack middleware?

混江龙づ霸主 提交于 2019-11-26 06:51:58
问题 What is Rack middleware in Ruby? I couldn\'t find any good explanation for what they mean by \"middleware\". 回答1: Rack as Design Rack middleware is more than "a way to filter a request and response" - it's an implementation of the pipeline design pattern for web servers using Rack. It very cleanly separates out the different stages of processing a request - separation of concerns being a key goal of all well designed software products. For example with Rack I can have separate stages of the

HTML5 video will not loop

久未见 提交于 2019-11-26 04:38:04
问题 I have a video as a background to a web page, and I am trying to get it to loop. Here is the code: <video autoplay=\'true\' loop=\'true\' muted=\'true\'> <source src=\'/admin/wallpapers/linked/4ebc66e899727777b400003c\' type=\'video/mp4\'></source> </video> Even though I have told the video to loop, it does not. I also tried to get it to loop with the onended attribute (as per this Mozilla support thread, I also tried that bit of jQuery). Nothing has worked so far. Is it an issue with Chrome,