---
allow_origins:
- '*'
allow_xss: false
mimetype: text/html
no_header: false
no_navheader: false
require_method:
- GET
require_permissions:
- view_nvr
resource-timestamp: 1647218821855624
resource-type: page
streaming-response: false
template_engine: mako

---
<%!
#Code Here runs once when page is first rendered. Good place for import statements.
import io
import base64
import PIL.Image
%>

<%
__doc__= "#Python Code here runs every page load"

if not kaithem.web.has_permission(kaithem.devices[kwargs['device']].config.get("kaithem.read_perms", '').strip()):
    raise RuntimeError('Security')

x = PIL.Image.open(io.BytesIO(kaithem.devices[kwargs['device']].tagpoints['bmp_snapshot'].value))
b = io.BytesIO()

x.save(b,'jpeg')

serve_file(b,"image/jpeg",kwargs['device']+".jpg")
b="data:image/jpeg;base64,"+base64.b64encode(b.getvalue()).decode()


%>

<h2>serve_jpg</h2>
<title>serve_jpg</title>

<div class="window">
<img src="${b}">
</div>
