Mix.install([
{:mint, "~> 1.5"},
{:kino, "~> 0.9.4"}
])
host = Kino.Input.text("Host")
user = Kino.Input.text("User")
password = Kino.Input.password("Password")
Kino.Layout.grid([host, user, password])
[host, user, password] = for var <- [host, user, password], do: Kino.Input.read(var)
{:ok, conn} = Mint.HTTP.connect(:http, host, 9200)
auth = "Basic #{Base.encode64("#{user}:#{password}")}"
{:ok, conn, request_ref} =
Mint.HTTP.request(
conn,
"GET",
"/publications/_count",
[{"Authorization", auth}],
""
)
receive do
message ->
case Mint.HTTP.stream(conn, message) do
:unknown -> IO.inspect(message)
{:ok, _conn, responses} -> IO.inspect(responses)
end
end