Get a fly swatter.
Flies attracted to carpet.
Flies are attracted to food so i further assume that there is some food material solid or liquid resident in the pile.
The eggs of the gnats hatch in the soil and the larva live and feed on fungal material found there.
Phorid flies are often the first pest drawn to these corpses followed by other scavenger insects such as carpet beetles mites and other flies.
For information on carpet moth treatment please click on this link.
We purchased some fly swatters a couple of years ago.
However blow flies are only attracted to fresh carcasses so they don t stay very long.
Tie the plastic bag tightly and properly close the trash bin to prevent gnats from getting attracted to the smell and breeding inside the trash can.
It is wise to begin looking at the first appearance of phorid flies before the corpse can begin emitting an unpleasant smell.
Eliminating and preventing phorid flies.
Others are attracted to sugary and vinegary substances.
Still others congregate near sewage and other filth.
House and blow flies lay eggs in animal manure so dispose of pet particularly dog waste frequently.
Remove rotten or overripe fruit from the kitchen dispose of all organic foods outside.
This works best for fruit flies because they are attracted to the fermented apple smell.
According to pest control company orkin different types of flies are attracted to different substances and materials.
These bugs lay eggs in soil where conditions are moist and there is decaying matter to feed upon.
Carpet beetles are often attracted to light and warmth indoors.
They work great if you have good aim.
Often they ll just fly inside your home but can also get inside on pets or clothes.
Moths are different from flies and from your question i will assume you actually have flies on your carpet.
The flies will go down into the jar drink the solution and become poisoned and trapped in the jar.
You may need to tear open your walls to remove the corpse.
Flies are attracted to light.
Some types of flies are drawn to fecal matter and rotting meat including carcasses.
Gnats are also attracted to decaying organic material wheres fruit flies only feed on produce.
Avoid using rat poison to kill rodents because the carcasses can attract flies.
Clean up animal feces such as in a cat s litter box right away.
Some species may infest seeds cereal pet.
If you have a lot of blow flies in your house there may be a dead animal trapped in your walls.