emptygif
Bahasa: Bahasa Indonesia

Semua bahasa dan framework

Hunchentoot Common Lisp

Snippet Common Lisp untuk Hunchentoot yang menjawab request ke /pixel.gif dengan empty GIF, yang di-decode sekali saat startup.

Hunchentoot Common Lisp

Instal
(ql:quickload '(:hunchentoot :cl-base64))
File
server.lisp
Jalankan
sbcl --load server.lisp
(ql:quickload '(:hunchentoot :cl-base64))

(defparameter *gif*
  (cl-base64:base64-string-to-usb8-array "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="))

(hunchentoot:define-easy-handler (pixel :uri "/pixel.gif") ()
  (setf (hunchentoot:content-type*) "image/gif"
        (hunchentoot:header-out :cache-control) "no-store")
  *gif*)

(hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 8080))

Kami telah menjalankan snippet ini dan membandingkan byte yang dikembalikannya.

Periksa

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

Situs resmi: Hunchentoot