emptygif
भाषा: हिन्दी

सभी भाषाएँ और फ़्रेमवर्क

Plug + Bandit Elixir

Plug + Bandit के लिए Elixir स्निपेट, जो /pixel.gif पर आने वाली रिक्वेस्ट का जवाब empty GIF से देता है। GIF स्टार्टअप पर एक ही बार डिकोड होता है।

Plug + Bandit Elixir

फ़ाइल
pixel.exs
चलाएँ
elixir pixel.exs
Mix.install([:plug, :bandit])

defmodule Pixel.Router do
  use Plug.Router

  @gif Base.decode64!("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")

  plug :match
  plug :dispatch

  get "/pixel.gif" do
    conn
    |> put_resp_content_type("image/gif", nil)
    |> put_resp_header("cache-control", "no-store")
    |> send_resp(200, @gif)
  end

  match _ do
    send_resp(conn, 404, "Not Found")
  end
end

Bandit.start_link(plug: Pixel.Router, port: 8080)
Process.sleep(:infinity)

हमने यह स्निपेट चलाया और इसके लौटाए बाइट्स की तुलना की।

जाँचें

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

आधिकारिक साइट: Plug + Bandit

Elixir में और