Sanitation is the number one cure for eliminating flies. You can eliminate the threat of these flies by keeping your home free of garbage. If you have a dog or cat, pick up feces as soon as possible to reduce the possibility of an infestation. Your garbage can should have a lid to prevent flies from finding a feeding ground.
You can also rid your home of flies by setting up traps. These traps can be placed indoors or outdoors. Some traps use lights to attract the flies, electrocuting them when they get close enough. Some people choose to use fly strips, which the flies stick to when they approach the bait, which can be molasses or raw meat.
Finally, you might turn to chemical measures. Insecticide sprayed on trash bins and other common landing spaces can prevent the spread of these dangerous pests.