nopaque/app/main/events.py
2019-08-27 10:40:29 +02:00

20 lines
457 B
Python

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)})