emptygif
Lingua: Italiano

Tutti i linguaggi e framework

HTTP.jl Julia

Uno snippet Julia per HTTP.jl che risponde alle richieste a /pixel.gif con la GIF vuota, decodificata una sola volta all'avvio.

HTTP.jl Julia

Installa
julia -e 'using Pkg; Pkg.add("HTTP")'
File
server.jl
Esegui
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)

Abbiamo eseguito questo snippet e confrontato i byte che ha restituito.

Verifica

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

Sito ufficiale: HTTP.jl

Altro in Julia