emptygif
Language: English

All languages and frameworks

HTTP.jl Julia

A Julia snippet for HTTP.jl that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

HTTP.jl Julia

Install
julia -e 'using Pkg; Pkg.add("HTTP")'
File
server.jl
Run
julia server.jl
using Base64
using HTTP

const GIF = base64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
const HEADERS = ["Content-Type" => "image/gif", "Cache-Control" => "no-store"]

router = HTTP.Router()
HTTP.register!(router, "GET", "/pixel.gif", _ -> HTTP.Response(200, HEADERS, GIF))

HTTP.serve(router, "0.0.0.0", 8080)

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: HTTP.jl

More in Julia