emptygif
语言: 简体中文

所有语言和框架

HTTP.jl Julia

一个用于 HTTP.jl 的 Julia 代码片段,以空 GIF 响应对 /pixel.gif 的请求,GIF 在启动时只解码一次。

HTTP.jl Julia

安装
julia -e 'using Pkg; Pkg.add("HTTP")'
文件
server.jl
运行
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)

我们运行了此代码片段,并比对了它返回的字节。

验证

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

官方网站: HTTP.jl

更多 Julia 示例