mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2025-10-29 18:59:57 +00:00
New Route that feeds live image data
This commit is contained in:
15
application/dashboard/templates/live.html
Normal file
15
application/dashboard/templates/live.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{%extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
|
||||
<img id="live_feed" src="{{url_for('dash.live_image')}}" alt="live_feed">
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
setInterval(() => {
|
||||
const img = document.getElementById('live_feed');
|
||||
img.src = `/dash/live_image?t=${Date.now()}`;
|
||||
}, 1000); // every 1 second
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -1,4 +1,11 @@
|
||||
from flask import Blueprint, render_template, request, jsonify, flash
|
||||
from flask import (
|
||||
Blueprint,
|
||||
render_template,
|
||||
request,
|
||||
jsonify,
|
||||
flash,
|
||||
send_from_directory,
|
||||
)
|
||||
from application.dashboard.models import AllowedPlate, LoggedItem
|
||||
from application import db
|
||||
from application.dashboard.forms import npForm
|
||||
@@ -48,3 +55,20 @@ def add():
|
||||
return render_template(
|
||||
"add.html", form=npForm(formdata=None), plates=Plates
|
||||
)
|
||||
|
||||
|
||||
@dash_blueprint.route("/live", methods=["GET"])
|
||||
@login_required
|
||||
def live():
|
||||
return render_template("live.html")
|
||||
|
||||
|
||||
@dash_blueprint.route("/live_image", methods=["GET"])
|
||||
@login_required
|
||||
def live_image():
|
||||
return send_from_directory(
|
||||
"static/live",
|
||||
"feed.png",
|
||||
as_attachment=False,
|
||||
conditional=True,
|
||||
)
|
||||
|
||||
BIN
application/static/live/feed.png
Normal file
BIN
application/static/live/feed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
Reference in New Issue
Block a user