import logging import redis import json from functools import wraps from flask import request, make_response, Blueprint, abort, Response from flask.ext.login import current_user, logout_user from data import model, userevent from app import app logger = logging.getLogger(__name__) realtime = Blueprint('realtime', __name__) def api_login_required(f): @wraps(f) def decorated_view(*args, **kwargs): if not current_user.is_authenticated(): abort(401) if (current_user and current_user.db_user() and current_user.db_user().organization): abort(401) if (current_user and current_user.db_user() and current_user.db_user().robot): abort(401) return f(*args, **kwargs) return decorated_view @realtime.route("/user/") @api_login_required def index(): debug_template = """