emptygif
Language: English

All languages and frameworks

Sinatra Ruby

A Ruby snippet for Sinatra that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

Sinatra Ruby

Install
gem install sinatra rackup puma
File
app.rb
Run
ruby app.rb
require "sinatra"

GIF = "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==".unpack1("m0").freeze

set :port, 8080

get "/pixel.gif" do
  content_type :gif
  cache_control :no_store
  GIF
end

We ran this snippet and compared the bytes it returned.

Check it

curl -sI http://localhost:8080/pixel.gif

Official site: Sinatra

More in Ruby