emptygif
Langue: Français

Tous les langages et frameworks

Kemal Crystal

Un extrait Crystal pour Kemal qui répond aux requêtes sur /pixel.gif avec le GIF vide, décodé une seule fois au démarrage.

Kemal Crystal

Installer
shards install # shard.yml: dependencies: kemal: github: kemalcr/kemal
Fichier
src/server.cr
Lancer
crystal run src/server.cr
require "base64"
require "kemal"

GIF = Base64.decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")

get "/pixel.gif" do |env|
  env.response.content_type = "image/gif"
  env.response.headers["Cache-Control"] = "no-store"
  env.response.write(GIF) # write the bytes; a non-String return value is ignored
  nil
end

Kemal.run(8080)

Vérifié par rapport à la documentation actuelle du framework.

Vérifier

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

Site officiel: Kemal

Autres extraits en Crystal