Skip to content

Instantly share code, notes, and snippets.

@nikhilbaby
Created December 10, 2019 09:20
Show Gist options
  • Save nikhilbaby/c580d335f8c3db2c1a809bcc296f5df5 to your computer and use it in GitHub Desktop.
Save nikhilbaby/c580d335f8c3db2c1a809bcc296f5df5 to your computer and use it in GitHub Desktop.
from flask import Flask, render_template, Response, copy_current_request_context
#from camera import VideoCamera
# from imagezmq import imagezmq
import cv2
from flask_socketio import SocketIO, emit
import requests
import threading
import time
# image_hub = imagezmq.ImageHub(open_port='tcp://10.6.2.101:5555', REQ_REP = False)
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
def threaded_function():
time.sleep(30)
while True:
rpi_name, frame = image_hub.recv_image()
emit('my', '123', broadcast=True)
# s.emit('main',{'data': 'main_thread_data'}, namespace='/test')
@socketio.on('connect')
def connect_handler():
print('Client connected')
return True
def start_runner():
thread = socketio.start_background_task(target=threaded_function)
# thread = threading.Thread(target=threaded_function)
# thread.start()
if __name__ == '__main__':
start_runner()
socketio.run(app, host='0.0.0.0', debug=True)'1ü
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment