from flask_login import current_user, login_required from flask_socketio import emit from .. import socketio import json @socketio.on('connect') @login_required def connect(): corpora = [] jobs = [] for corpus in current_user.corpora: corpora.append(corpus.to_dict()) for job in current_user.jobs: jobs.append(job.to_dict()) emit('corpora', {'data': json.dumps(corpora)}) emit('jobs', {'data': json.dumps(jobs)})