emptygif
Idioma: Español

Todos los lenguajes y frameworks

HTTP.jl Julia

Un fragmento en Julia para HTTP.jl que responde a las peticiones a /pixel.gif con el GIF vacío, decodificado una sola vez al arrancar.

HTTP.jl Julia

Instalar
julia -e 'using Pkg; Pkg.add("HTTP")'
Archivo
server.jl
Ejecutar
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)

Ejecutamos este fragmento y comparamos los bytes que devolvió.

Comprobar

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

Sitio oficial: HTTP.jl

Más en Julia