emptygif
Dil: Türkçe

Tüm diller ve framework'ler

Scotty Haskell

Scotty için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir Haskell örneği.

Scotty Haskell

Kurulum
build-depends: base, bytestring, base64-bytestring, scotty
Dosya
Main.hs
Çalıştır
cabal run
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Base64 as Base64
import qualified Data.ByteString.Lazy as BL
import Web.Scotty

-- A top-level constant: decoded once, on first use.
gif :: BL.ByteString
gif = BL.fromStrict (Base64.decodeLenient "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")

main :: IO ()
main = scotty 8080 $
  get "/pixel.gif" $ do
    setHeader "Content-Type" "image/gif"
    setHeader "Cache-Control" "no-store"
    raw gif

Framework'ün güncel belgelerine göre kontrol edildi.

Kontrol et

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

Resmî site: Scotty

Haskell için daha fazlası