livebook as api

This commit is contained in:
Chang CL
2025-08-20 11:34:38 +08:00
parent 24d8060930
commit ee998fec4b

View File

@@ -1,9 +1,24 @@
# livebook api
```elixir
Mix.install([
{:kino, "~> 0.16.1"},
{:plug, "~> 1.18"}
])
```
## Section
https://news.livebook.dev/livebook-0.13-expose-an-http-api-from-your-notebook-2wE6GY
```elixir
Kino.Proxy.listen(fn conn ->
Plug.Conn.send_resp(conn, 200, "hello world!")
end)
```
replace ip address and port numbers of livebook server
```
curl -L "http://ipaddress:port/proxy/sessions/4gqhbukjeigg5ht4zphpi7gihyoyl247x2rhcs63nnsd2dyj"
```