Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kcuric committed Jan 3, 2020
2 parents c18d005 + f5a64be commit 66312a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
24 changes: 23 additions & 1 deletion server/app.py
Original file line number Diff line number Diff line change
@@ -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')
3 changes: 2 additions & 1 deletion server/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<body>
<h1>DIY Survailence System</h1>
<p>Running the app.py</p>
<img src="{{ url_for('video_feed') }}">
</body>
</html>
</html>

0 comments on commit 66312a7

Please sign in to comment.