adding multiple clients can stream feature

This commit is contained in:
Eben 2020-10-03 19:46:38 +01:00
parent 738c8a8783
commit ff4844914c
3 changed files with 22 additions and 22 deletions

BIN
.DS_Store vendored

Binary file not shown.

30
main.py
View File

@ -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)

View File

@ -149,19 +149,6 @@ body {
</button>
</a>
</div>
<form method = "post">
<div class="camera-movement">
<a href=# id=center>
<button>
<i class="fa fa-camera fa-3x" style="color: white" aria-hidden="true"></i>
</button>
</a>
</div>
</form>
</div>
@ -182,6 +169,7 @@ button.onclick = function() {
div.style.display = 'block';
}
};
</script>
</body>