feat: added some features
This commit is contained in:
24
app.py
24
app.py
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user