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'})
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'})
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'})
def leave_channel(name): global channels channels = load_channels() channels[name]['count'] -= 1 save_channels(channels) return jsonify({'status': 'ok'})
def join_channel(name): global channels channels = load_channels() channels[name]['count'] += 1 save_channels(channels) return jsonify({'status': 'ok', 'id': channels[name]['count']})
def delete_channel(name): global channels channels = load_channels() del channels[name] save_channels(channels) return jsonify({'status': 'ok'})