@app.route('/api/v1/categories/<category>/acts', methods=['GET'])
def list_acts(category=None):
    global count_requests
    count_requests += 1
    if (request.method == 'GET'):
        temp_path = ((((DB + '/') + category) + '/') + GLOBAL_LIST)
        if (category not in os.listdir(DB)):
            return Response('[]', status=400, mimetype='application/json')
        start = request.args.get('start')
        end = request.args.get('end')
        if ((start == None) and (end == None)):
            if os.path.exists(temp_path):
                data = pd.read_csv(temp_path)
                rows = data.shape[0]
                if (rows == 0):
                    return Response('[]', status=204, mimetype='application/json')
                elif (rows >= 100):
                    return Response('[]', status=413, mimetype='application/json')
                else:
                    response_data = data.to_json(orient='records')
                    return Response(response_data, status=200, mimetype='application/json')
            else:
                return Response('[]', status=204, mimetype='application/json')
        else:
            start = int(start)
            end = int(end)
            temp_path = ((((DB + '/') + category) + '/') + GLOBAL_LIST)
            if (category not in os.listdir(DB)):
                return Response('[]', status=400, mimetype='application/json')
            if os.path.exists(temp_path):
                data = pd.read_csv(temp_path)
                data['timestamp'] = pd.to_datetime(data['timestamp'], format='%d-%m-%Y:%S-%M-%H')
                data['actId'] = data['actId'].astype(int)
                sorted_data = data.sort_values(['timestamp', 'actId'], ascending=[False, False], axis=0)
                rows = data.shape[0]
                if ((start < 1) or (end > rows)):
                    return Response('[]', status=400, mimetype='application/json')
                if (rows == 0):
                    return Response('[]', status=204, mimetype='application/json')
                else:
                    required_data = pd.DataFrame(sorted_data.iloc[(start - 1):end, :])
                    if (required_data.shape[0] > 100):
                        return Response('[]', status=413, mimetype='application/json')
                    required_data['timestamp'] = pd.to_datetime(required_data['timestamp'], format='%d-%m-%Y:%S-%M-%H')
                    required_data['timestamp'] = required_data['timestamp'].astype(str)
                    response_data = required_data.to_json(orient='records')
                    return Response(response_data, status=200, mimetype='application/json')
            else:
                return Response('[]', status=204, mimetype='application/json')
    else:
        return Response('{}', status=405, mimetype='application/json')
@app.route('/api/v1/categories/<category>/acts', methods=['GET'])
def list_acts(category=None):
    global count_requests
    count_requests += 1
    if (request.method == 'GET'):
        temp_path = ((((DB + '/') + category) + '/') + GLOBAL_LIST)
        if (category not in os.listdir(DB)):
            return Response('[]', status=400, mimetype='application/json')
        start = request.args.get('start')
        end = request.args.get('end')
        if ((start == None) and (end == None)):
            if os.path.exists(temp_path):
                data = pd.read_csv(temp_path)
                rows = data.shape[0]
                if (rows == 0):
                    return Response('[]', status=204, mimetype='application/json')
                elif (rows >= 100):
                    return Response('[]', status=413, mimetype='application/json')
                else:
                    response_data = data.to_json(orient='records')
                    return Response(response_data, status=200, mimetype='application/json')
            else:
                return Response('[]', status=204, mimetype='application/json')
        else:
            start = int(start)
            end = int(end)
            temp_path = ((((DB + '/') + category) + '/') + GLOBAL_LIST)
            if (category not in os.listdir(DB)):
                return Response('[]', status=400, mimetype='application/json')
            if os.path.exists(temp_path):
                data = pd.read_csv(temp_path)
                data['timestamp'] = pd.to_datetime(data['timestamp'], format='%d-%m-%Y:%S-%M-%H')
                data['actId'] = data['actId'].astype(int)
                sorted_data = data.sort_values(['timestamp', 'actId'], ascending=[False, False], axis=0)
                rows = data.shape[0]
                if ((start < 1) or (end > rows)):
                    return Response('[]', status=400, mimetype='application/json')
                if (rows == 0):
                    return Response('[]', status=204, mimetype='application/json')
                else:
                    required_data = pd.DataFrame(sorted_data.iloc[(start - 1):end, :])
                    if (required_data.shape[0] > 100):
                        return Response('[]', status=413, mimetype='application/json')
                    required_data['timestamp'] = pd.to_datetime(required_data['timestamp'], format='%d-%m-%Y:%S-%M-%H')
                    required_data['timestamp'] = required_data['timestamp'].astype(str)
                    response_data = required_data.to_json(orient='records')
                    return Response(response_data, status=200, mimetype='application/json')
            else:
                return Response('[]', status=204, mimetype='application/json')
    else:
        return Response('{}', status=405, mimetype='application/json')