예제 #1
0
def upload_search(name, id):
    global channels
    channels = load_channels()
    data = json.loads(request.data.decode('utf-8'))
    channels[name]['results'] = {**channels[name]['results'], **data}  # merge
    channels[name]['result_count'] += 1
    save_channels(channels)
    return jsonify({'status': 'ok'})
예제 #2
0
def set_search(name, term):
    global channels
    channels = load_channels()
    channels[name]['search'] = term
    channels[name]['result_count'] = 0
    channels[name]['results'] = {}
    save_channels(channels)
    return jsonify({'status': 'ok'})
예제 #3
0
def create_channel(name):
    global channels
    channels = load_channels()
    channels[name] = {
        'count': 0,
        'search': None,
        'results': {},
        'result_count': 0
    }
    save_channels(channels)
    return jsonify({'status': 'ok'})
예제 #4
0
def leave_channel(name):
    global channels
    channels = load_channels()
    channels[name]['count'] -= 1
    save_channels(channels)
    return jsonify({'status': 'ok'})
예제 #5
0
def join_channel(name):
    global channels
    channels = load_channels()
    channels[name]['count'] += 1
    save_channels(channels)
    return jsonify({'status': 'ok', 'id': channels[name]['count']})
예제 #6
0
def delete_channel(name):
    global channels
    channels = load_channels()
    del channels[name]
    save_channels(channels)
    return jsonify({'status': 'ok'})