From f5a64be2faab2a63056198b1afb8c0ac8326e0e6 Mon Sep 17 00:00:00 2001 From: kcuric Date: Fri, 3 Jan 2020 16:44:20 +0000 Subject: [PATCH] #9 Flask app slightly modified --- server/app.py | 24 +++++++++++++++++++++++- server/templates/index.html | 3 ++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/server/app.py b/server/app.py index 5414b80..d8ce837 100644 --- a/server/app.py +++ b/server/app.py @@ -1,10 +1,32 @@ -from flask import Flask, render_template +from flask import Flask, render_template, Response app = Flask(__name__) +import socket + + +ip = "0.0.0.0" +port = 5005 + +sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +sock.bind((ip, port)) + +def rec(): + + while True: + data, addr = sock.recvfrom(65535) + print(len(data)) + yield (b'--frame\r\n' + b'Content-Type: image/jpeg\r\n\r\n' + data + b'\r\n') + @app.route('/') def index(): return render_template('index.html') +@app.route('/video_feed') +def video_feed(): + return Response(rec(), mimetype='multipart/x--mixed-replace; boundary=frame') + + if __name__ == '__main__': app.run(ssl_context='adhoc') diff --git a/server/templates/index.html b/server/templates/index.html index b69c943..c82f484 100644 --- a/server/templates/index.html +++ b/server/templates/index.html @@ -9,5 +9,6 @@

DIY Survailence System

Running the app.py

+ - \ No newline at end of file +