feat: added some features

This commit is contained in:
2020-05-17 19:38:08 +02:00
parent f69cc0b45c
commit 8b268ef48c
8 changed files with 425 additions and 93 deletions

24
app.py
View File

@@ -1,8 +1,15 @@
from control.camera import Camera
from control.walle import WallE
import base64
# import eventlet
# eventlet.monkey_patch()
from flask import Flask, jsonify, send_file, Response
from flask_socketio import SocketIO
from control.camera import Camera
from control.walle import WallE
DATA_URL_PREFIX = 'data:image/jpeg;base64,'
# DEBUG = True
boundary = 'lkajflkasdjlkfaj'
@@ -11,9 +18,21 @@ app = Flask(__name__, static_url_path='', static_folder='client/dist')
app.config.from_object(__name__)
sio = SocketIO(app)
# camera = Camera()
walle = WallE()
def camera_thread():
while True:
for image in camera.generate_images():
if not image:
break
image_url = DATA_URL_PREFIX + base64.b64encode(image).decode('ascii')
sio.emit('camera_image', {
'image': image_url,
}, broadcast=True)
@app.route('/')
def index():
return send_file('client/dist/index.html')
@@ -34,4 +53,5 @@ def message(directions):
if __name__ == '__main__':
# eventlet.spawn(camera_thread)
sio.run(app, host='0.0.0.0')