This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
augie/webapp/lib/augie_web/live/camera_live.ex
2020-05-02 19:09:46 +12:00

29 lines
569 B
Elixir

defmodule AugieWeb.CameraLive do
use Phoenix.LiveView
@moduledoc """
A Liveview which streams images from the raspberry pi camera.
"""
def render(assigns) do
~L"""
<div class="card">
<div class="card-divider">
<h4>Camera</h4>
</div>
<img src="<%= @img_src %>">
</div>
"""
end
def mount(_params, _context, socket) do
socket =
if connected?(socket) do
assign(socket, img_src: "/camera/stream")
else
assign(socket, img_src: "/camera/static")
end
{:ok, socket}
end
end