From ff4844914c9c8ed972f26a9effaded3db8e4e27c Mon Sep 17 00:00:00 2001 From: Eben Date: Sat, 3 Oct 2020 19:46:38 +0100 Subject: [PATCH] adding multiple clients can stream feature --- .DS_Store | Bin 6148 -> 6148 bytes main.py | 30 +++++++++++++++++++++--------- templates/index.html | 14 +------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.DS_Store b/.DS_Store index aa24c4acfab2706323d4f60fc1c732509f580719..ce70799a691acdd4acacb06f749678064e6b0655 100644 GIT binary patch delta 354 zcmZoMXfc=|#>B!ku~2NHo+2an#(>?7iytsEF>+7lVKSXu%5=Ftsl2!#DJMUPfq~&` zQbA5;afyM!4Mrwr7FITP4o)s^Zf-tq&e-6L{PN(E#FEltr^KRo0h!>;l+>ieqVUX= zl8lhlJlCAmveZ2PBA>*P)S_sR;*k9O9H0USJ25FNGqpTkK*TveuOu-uFSQ749>|RP z#G;t+%)FHRa;N;#yp&?F2B_&^c0giD2GAf5WrxHCKsPclaB_0S3rJK~8=0EwC;*9C z9ffLha|0a(6JxX5T22lQNp-iNxYDM+S+kccUAFwtVX!U+Mn(wDAPA))6f*ln(r2}OdHx?Q&Zf57;=KzM_=8MeVnJ4p$IC22ZVFKyh93irX F836dPWZ3`! delta 112 zcmZoMXfc=|#>B)qu~2NHo+2aH#(>?7j9im>SWH#97&0017*ZHg87dg`7%~`27;+hM zJah7slXCKt7#J7?7#J8^CmXRmnyk&%yIF>Vn`L5y`et?xeh#2{n*}+(Gf(ChapVB1 PWME`qVA&iYvW6J|)4v%# diff --git a/main.py b/main.py index f233a4a..91547d5 100644 --- a/main.py +++ b/main.py @@ -1,26 +1,38 @@ #Modified by smartbuilds.io #Date: 27.09.20 -#Desc: This scrtipt script.. +#Desc: This web application serves a motion JPEG stream # main.py - # import the necessary packages -from flask import Flask, render_template, Response +from flask import Flask, render_template, Response, request from camera import VideoCamera +import time +import threading +import os + +pi_camera = VideoCamera(flip=False) # flip pi camera if upside down. + +# App Globals (do not edit) app = Flask(__name__) + @app.route('/') def index(): - # rendering webpage - return render_template('index.html') + return render_template('index.html') #you can customze index.html here + def gen(camera): + #get camera frame while True: - #get camera frame frame = camera.get_frame() yield (b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n') + @app.route('/video_feed') def video_feed(): - return Response(gen(VideoCamera()), + return Response(gen(pi_camera), mimetype='multipart/x-mixed-replace; boundary=frame') + if __name__ == '__main__': - # defining server ip address and port - app.run(host='0.0.0.0',port='5000', debug=False) + + app.run(host='0.0.0.0', debug=False) + + + diff --git a/templates/index.html b/templates/index.html index fa5fb62..2c7aaf3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -149,19 +149,6 @@ body { - -
- -
- - - - - -
-
@@ -182,6 +169,7 @@ button.onclick = function() { div.style.display = 'block'; } }; +