Dogs don't do spite. Seriously, the part of the brain in humans that drives that sort of behaviour just hasn't developed in dogs.
She might be marking - less likely in female dogs than males, but possible nonetheless. Dogs that mark do that because they are unsure of their 'place' in the household. If that's the case, everyone needs to give her more reassurance, build her confidence.
Or, she might simply have needed to toilet, and if the choice was between a rug and a hard floor, most dogs prefer a softer surface. If that's the case, she needs to be taken outside more often.
Either way, clean the rug with an enzymatic cleaner to remove any trace of smell and leave it down for 10 minutes before wiping it up to allow the enzymes to get to work. Maybe even lift the rug, or at least block it off from her if you are not there to supervise.
And, hard as it is, try not to show any frustration or get cross with her. That will just make her reluctant to toilet where you are, so she will seek or create opportunities to toilet when you are not there. And you don't want that.