emptygif
Harshe: Hausa

Duk harsuna da frameworks

Kemal Crystal

Snippet na Crystal don Kemal da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

Kemal Crystal

Girkawa
shards install # shard.yml: dependencies: kemal: github: kemalcr/kemal
Fayil
src/server.cr
Gudanar
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)

An duba shi da takardun bayani na yanzu na framework ɗin.

Duba shi

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

Shafin hukuma: Kemal

Ƙari a Crystal