示例#1
0
def _playing(db, storage, registry):
    if playing:
        storage = DistributedStorage.bind(current_app.config)
        meta = storage.get(playing.song_id, None)
        meta['time_add'] = playing.timestamp
        meta['added_by'] = User.get(db, playing.user_id).dict()
    else:
        meta = None
    return Response(json.dumps(meta),
                    mimetype='application/json')
示例#2
0
def main(args, root_logger, handler):
    global messages
    config = load_config(args)

    storage = DistributedStorage.bind(config)
    storage.initialize()

    app.config.update(config)

    if not config['debug']:
        app.logger.addHandler(handler)
    else:
        app.debug = True
        assets.debug = True

    if not config.get('secret_key'):
        raise Exception('Please set a secret key!')

    app.secret_key = str(config['secret_key'])
    configure_auth(app)

    http_server = WSGIServer((config['host'], int(config['port'])),
                              app, handler_class=WebSocketHandler)
    http_server.serve_forever()