emptygif
Langue: Français

Tous les langages et frameworks

HTTP.jl Julia

Un extrait Julia pour HTTP.jl qui répond aux requêtes sur /pixel.gif avec le GIF vide, décodé une seule fois au démarrage.

HTTP.jl Julia

Installer
julia -e 'using Pkg; Pkg.add("HTTP")'
Fichier
server.jl
Lancer
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)

Nous avons exécuté cet extrait et comparé les octets qu’il a renvoyés.

Vérifier

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

Site officiel: HTTP.jl

Autres extraits en Julia