emptygif
Sprache: Deutsch

Alle Sprachen und Frameworks

Kemal Crystal

Ein Crystal-Snippet für Kemal, das Anfragen an /pixel.gif mit dem leeren GIF beantwortet, das einmal beim Start dekodiert wird.

Kemal Crystal

Installieren
shards install # shard.yml: dependencies: kemal: github: kemalcr/kemal
Datei
src/server.cr
Ausführen
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)

Mit der aktuellen Dokumentation des Frameworks abgeglichen.

Prüfen

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

Offizielle Website: Kemal

Mehr in Crystal