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 %>">
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")
{:ok, socket}