@app.route('/api/v1/categories', methods=['GET', 'POST'])
def list_categories():
    global count_requests
    count_requests += 1
    if (not os.path.exists(DB)):
        os.makedirs(DB, exist_ok=True)
    if (request.method == 'GET'):
        categories = os.listdir(DB)
        if (not categories):
            return Response('{}', status=204, mimetype='application/json')
        response_data = {}
        for category in categories:
            response_data[category] = len(os.listdir(((DB + '/') + category)))
        return jsonify(response_data)
    elif (request.method == 'POST'):
        category = json.loads(request.data)[0]
        if (category in os.listdir(DB)):
            return Response('{}', status=400, mimetype='application/json')
        os.makedirs(((DB + '/') + category), exist_ok=True)
        return Response('{}', status=201, mimetype='application/json')
    else:
        return Response('{}', status=405, mimetype='application/json')
@app.route('/api/v1/categories', methods=['GET', 'POST'])
def list_categories():
    global count_requests
    count_requests += 1
    if (not os.path.exists(DB)):
        os.makedirs(DB, exist_ok=True)
    if (request.method == 'GET'):
        categories = os.listdir(DB)
        if (not categories):
            return Response('{}', status=204, mimetype='application/json')
        response_data = {}
        for category in categories:
            response_data[category] = len(os.listdir(((DB + '/') + category)))
        return jsonify(response_data)
    elif (request.method == 'POST'):
        category = json.loads(request.data)[0]
        if (category in os.listdir(DB)):
            return Response('{}', status=400, mimetype='application/json')
        os.makedirs(((DB + '/') + category), exist_ok=True)
        return Response('{}', status=201, mimetype='application/json')
    else:
        return Response('{}', status=405, mimetype='application/json')